ADTF
|
Serves as component for interaction with operating system processes. More...
Functions | |
uint64_t | getCurrentProcessId () |
Get the current process id. More... | |
uint32_t | execute (const a_util::filesystem::Path &executable_file, const std::string &arguments, const a_util::filesystem::Path &working_dir, bool wait_for_exit) |
Run an executable as detached process and optionally wait for the application to exit. More... | |
uint32_t | execute (const a_util::filesystem::Path &executable_file, const std::string &arguments, const a_util::filesystem::Path &working_dir, std::string &std_out) |
Run an executable and wait for the application to exit. More... | |
uint32_t | execute (const a_util::filesystem::Path &executable_file, const std::string &arguments, const a_util::filesystem::Path &working_dir, std::string &std_out, std::string &std_err) |
Start an executable and wait for the application to exit. More... | |
std::string | getEnvVar (const std::string &environment_variable_name) |
Retrieve the current value of the environment variable given in environment_variable_name . More... | |
std::string | getEnvVar (const std::string &environment_variable_name, const std::string &default_value) |
Retrieve the current value of the environment variable given in environment_variable_name . More... | |
void | setEnvVar (const std::string &environment_variable_name, const std::string &environment_variable_value) |
Set an environment variable with a given value to the current process environment areas. More... | |
Serves as component for interaction with operating system processes.
uint32_t a_util::process::execute | ( | const a_util::filesystem::Path & | executable_file, |
const std::string & | arguments, | ||
const a_util::filesystem::Path & | working_dir, | ||
bool | wait_for_exit | ||
) |
Run an executable as detached process and optionally wait for the application to exit.
[in] | executable_file | Path to executable or command to execute. |
[in] | arguments | Arguments passing to the executable. |
[in] | working_dir | Working directory. If empty the current working directory is used. |
[in] | wait_for_exit | Specifies whether the function should wait for the application to close down. only if set to true the return value will be used for applications return value. |
uint32_t a_util::process::execute | ( | const a_util::filesystem::Path & | executable_file, |
const std::string & | arguments, | ||
const a_util::filesystem::Path & | working_dir, | ||
std::string & | std_out | ||
) |
Run an executable and wait for the application to exit.
[in] | executable_file | Path to executable or command to execute. |
[in] | arguments | Arguments passing to the executable. |
[in] | working_dir | Working directory. If empty the current working directory is used. |
[in] | std_out | Standard out of the executed application |
uint32_t a_util::process::execute | ( | const a_util::filesystem::Path & | executable_file, |
const std::string & | arguments, | ||
const a_util::filesystem::Path & | working_dir, | ||
std::string & | std_out, | ||
std::string & | std_err | ||
) |
Start an executable and wait for the application to exit.
[in] | executable_file | executable file or command to call. |
[in] | arguments | Arguments passing to the executable. |
[in] | working_dir | Working directory. If empty the current working directory is used. |
[in] | std_out | Standard out of the program started. |
[in] | std_err | Standard error of the program started. |
uint64_t a_util::process::getCurrentProcessId | ( | ) |
Get the current process id.
std::string a_util::process::getEnvVar | ( | const std::string & | environment_variable_name | ) |
Retrieve the current value of the environment variable given in environment_variable_name
.
[in] | environment_variable_name | The environment variable name to retrieve the value for. |
environment_variable_name
. std::system_error | If the environment variable could not be retrieved. |
std::runtime_error | If the environment variable could not be retrieved. |
std::string a_util::process::getEnvVar | ( | const std::string & | environment_variable_name, |
const std::string & | default_value | ||
) |
Retrieve the current value of the environment variable given in environment_variable_name
.
If the environment variable is not set the default_value
is returned.
[in] | environment_variable_name | The environment variable name to retrieve the value for. |
[in] | default_value | The default value if variable is not set. |
environment_variable_name
or default_value
void a_util::process::setEnvVar | ( | const std::string & | environment_variable_name, |
const std::string & | environment_variable_value | ||
) |
Set an environment variable with a given value to the current process environment areas.
Depending on the underlying process API the environment will be either copied to any child process or not. When using any of the execute() functions, the new process uses a copy of the environment of the calling process.
[in] | environment_variable_name | the environment variable name to set the value for. |
[in] | environment_variable_value | the environment variable value. |
std::system_error | If environment variable could not be set. |
std::runtime_error | If environment variable could not be set. |