1 #ifndef WREPORT_SUBPROCESS_H 2 #define WREPORT_SUBPROCESS_H 37 bool m_terminated =
false;
38 int m_stdin[2] = { -1, -1 };
39 int m_stdout[2] = { -1, -1 };
40 int m_stderr[2] = { -1, -1 };
41 Redirect m_stdin_action = Redirect::UNCHANGED;
42 Redirect m_stdout_action = Redirect::UNCHANGED;
43 Redirect m_stderr_action = Redirect::UNCHANGED;
46 virtual void pre_fork();
49 virtual void post_fork_parent();
52 virtual void post_fork_child();
59 virtual int main() noexcept = 0;
63 bool close_fds =
true;
75 bool start_new_session =
false;
78 int get_stdin()
const;
80 int get_stdout()
const;
82 int get_stderr()
const;
85 void set_stdin(
int fd);
87 void set_stdin(Redirect val);
89 void set_stdout(
int fd);
91 void set_stdout(Redirect val);
93 void set_stderr(
int fd);
95 void set_stderr(Redirect val);
116 pid_t
pid()
const {
return m_pid; }
122 int returncode()
const;
140 void send_signal(
int sig);
149 static std::string format_raw_returncode(
int raw_returncode);
156 int main() noexcept
override;
164 std::vector<std::string>
env;
169 Popen(std::initializer_list<std::string> args);
172 void copy_env_from_parent();
174 void setenv(
const std::string& key,
const std::string& val);
std::string executable
pathname to the executable of the child process, defaults to args[0] if empty
Definition: subprocess.h:162
Definition: subprocess.h:153
int raw_returncode() const
Return the raw return code as returned by wait(2)
Definition: subprocess.h:125
std::vector< std::string > args
argv of the child process
Definition: subprocess.h:160
std::string cwd
Change to this directory in the child process.
Definition: subprocess.h:72
bool terminated() const
Return true if the process has terminated.
Definition: subprocess.h:131
pid_t pid() const
Return the PID of the subprocess, or 0 if it has not started yet.
Definition: subprocess.h:116
bool started() const
Return true if the process has started.
Definition: subprocess.h:128
String functions.
Definition: benchmark.h:13
std::vector< std::string > env
environment variables to use for the child process
Definition: subprocess.h:164
Definition: subprocess.h:32
std::vector< int > pass_fds
Do not close these file descriptors in the child process (implies close_fds = true) ...
Definition: subprocess.h:69