userver
C++ Async Framework
Toggle main menu visibility
Documentation
API Groups
Namespaces
Reference
Class List
Class Index
File List
Macros
All
e
i
l
r
t
u
Functions
Macros
e
i
l
r
t
u
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Concepts
Loading...
Searching...
No Matches
process_starter.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/engine/subprocess/process_starter.hpp
4
/// @brief @copybrief engine::subprocess::ProcessStarter
5
6
#
include
<
optional
>
7
#
include
<
string
>
8
#
include
<
vector
>
9
10
#
include
<
userver
/
engine
/
subprocess
/
child_process
.
hpp
>
11
#
include
<
userver
/
engine
/
subprocess
/
environment_variables
.
hpp
>
12
#
include
<
userver
/
engine
/
task
/
task_processor_fwd
.
hpp
>
13
14
USERVER_NAMESPACE_BEGIN
15
16
namespace
engine::
ev
{
17
class
ThreadControl;
18
}
// namespace engine::ev
19
20
namespace
engine::subprocess {
21
22
/// @brief Structure of settings for executing commands in the OS.
23
struct
ExecOptions
final
{
24
/// EnvironmentVariables for the environment in execution, or `std::nullopt`
25
/// to use GetCurrentEnvironmentVariables()
26
std::optional<
EnvironmentVariables
>
env
{};
27
/// EnvironmentVariablesUpdate for the update environment before execution, or
28
/// `std::nullopt` to leave `env` as is
29
std::optional<
EnvironmentVariablesUpdate
>
env_update
{};
30
/// File path to be redirected stdout, or `std::nullopt` to use the service's
31
/// stdout
32
std::optional<std::string>
stdout_file
{};
33
/// File path to be redirected stderr, or `std::nullopt` to use the service's
34
/// stderr
35
std::optional<std::string>
stderr_file
{};
36
/// If `false`, `executable_path` is treated as absolute path or a relative path.
37
/// If `true`, and `executable_path` does not contain `/`, and PATH in environment
38
/// variables, then it will be searched in the colon-separated list of
39
/// directory pathnames specified in the PATH environment variable.
40
/// If `true`, and `executable_path` contains `/`, `executable_path` is treated as absolute
41
/// path or a relative path.
42
bool
use_path
{
false
};
43
};
23
struct
ExecOptions
final
{
…
};
44
45
/// @ingroup userver_clients
46
///
47
/// @brief Creates a new OS subprocess and executes a command in it.
48
class
ProcessStarter
{
49
public
:
50
/// @param task_processor will be used for executing asynchronous fork + exec.
51
/// `main-task-processor is OK for this purpose.
52
explicit
ProcessStarter(TaskProcessor& task_processor);
53
54
/// @param executable_path the absolute path or relative path. If `use_path` is
55
/// `true`, and `executable_path` does not contain `/`, then it will be searched in
56
/// the colon-separated list of directory pathnames specified in the PATH
57
/// environment variable. More details @ref ExecOptions::use_path
58
/// @param args exact args passed to the executable
59
/// @param options @ref ExecOptions settings
60
/// @throws std::runtime_error if `use_path` is `true`, `executable_path` contains `/`
61
/// and PATH not in environment variables
62
ChildProcess
63
Exec
(
const
std::string& executable_path,
const
std::vector<std::string>& args, ExecOptions&& options = {});
64
65
private
:
66
ev
::ThreadControl& thread_control_;
67
};
48
class
ProcessStarter
{
…
};
68
69
}
// namespace engine::subprocess
70
71
USERVER_NAMESPACE_END
userver
engine
subprocess
process_starter.hpp
Generated on Wed Apr 30 2025 15:52:08 for userver by
Doxygen
1.13.2