userver: userver/engine/subprocess/process_starter.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 <unordered_map>
9#include <vector>
10
11#include <userver/engine/subprocess/child_process.hpp>
12#include <userver/engine/subprocess/environment_variables.hpp>
13#include <userver/engine/task/task_processor_fwd.hpp>
14
15USERVER_NAMESPACE_BEGIN
16
17namespace engine {
18
19namespace ev {
20class ThreadControl;
21} // namespace ev
22
23namespace subprocess {
24
25/// @ingroup userver_clients
26///
27/// @brief Creates a new OS subprocess and executes a command in it.
29 public:
30 explicit ProcessStarter(TaskProcessor& task_processor);
31
32 /// `env` redefines all environment variables.
33 ChildProcess Exec(
34 const std::string& command, const std::vector<std::string>& args,
35 const EnvironmentVariables& env,
36 // TODO: use something like pipes instead of path to files
37 const std::optional<std::string>& stdout_file = std::nullopt,
38 const std::optional<std::string>& stderr_file = std::nullopt);
39
40 /// Variables from `env_update` will be added to current environment.
41 /// Existing values will be replaced.
42 ChildProcess Exec(
43 const std::string& command, const std::vector<std::string>& args,
45 // TODO: use something like pipes instead of path to files
46 const std::optional<std::string>& stdout_file = std::nullopt,
47 const std::optional<std::string>& stderr_file = std::nullopt);
48
49 /// Exec subprocess using current environment.
50 ChildProcess Exec(
51 const std::string& command, const std::vector<std::string>& args,
52 // TODO: use something like pipes instead of path to files
53 const std::optional<std::string>& stdout_file = std::nullopt,
54 const std::optional<std::string>& stderr_file = std::nullopt);
55
56 private:
57 ev::ThreadControl& thread_control_;
58};
59
60} // namespace subprocess
61} // namespace engine
62
63USERVER_NAMESPACE_END