Fray Engine
Loading...
Searching...
No Matches
fray::process Namespace Reference

Functions

F_err spawn (const std::vector< std::string > &command, const std::filesystem::path &workingDirectory, const std::vector< std::pair< std::string, std::string > > &environment={})
 Starts a child process without waiting for it (fire and forget). The child inherits this process's stdio and the given environment variables, and runs in workingDirectory. Side effect: the variables are set in this process's own environment (not restored) before spawning, so call it while the engine is still single-threaded. On Windows the command runs through cmd /c; elsewhere it uses fork + execvp (a child that cannot chdir or exec exits with 126 / 127, which is not reported to the caller).

Function Documentation

◆ spawn()

F_err fray::process::spawn ( const std::vector< std::string > & command,
const std::filesystem::path & workingDirectory,
const std::vector< std::pair< std::string, std::string > > & environment = {} )
inline

Starts a child process without waiting for it (fire and forget). The child inherits this process's stdio and the given environment variables, and runs in workingDirectory. Side effect: the variables are set in this process's own environment (not restored) before spawning, so call it while the engine is still single-threaded. On Windows the command runs through cmd /c; elsewhere it uses fork + execvp (a child that cannot chdir or exec exits with 126 / 127, which is not reported to the caller).

Parameters
commandProgram followed by its arguments; must not be empty.
workingDirectoryDirectory the child runs in.
environmentName/value pairs added to the environment, overwriting existing values. Empty by default.
Returns
errors::NONE once the child was started; errors::FAILED_SPAWN_PROCESS if command is empty or fork / CreateProcess failed.

Definition at line 38 of file process_manager.hpp.