23 #ifndef __PLUGINS_OPENPRS_UTILS_PROC_H_ 24 #define __PLUGINS_OPENPRS_UTILS_PROC_H_ 26 #include <logging/logger.h> 28 #include <boost/asio.hpp> 42 SubProcess(
const char *progname,
const char *file,
const char *argv[],
const char *envp[]);
43 SubProcess(
const char *progname,
const char *file,
const char *argv[],
const char *envp[],
55 {
return pipe_stdin_w_; }
60 {
return pipe_stdout_r_; }
65 {
return pipe_stderr_r_; }
69 boost::asio::posix::stream_descriptor &
sd_stdin()
75 {
return sd_stdout_; }
80 {
return sd_stderr_; }
82 void kill(
int signum);
86 pid_t run_proc(
const char *file,
const char *argv[],
const char *envp[],
89 void run_proc(
const char *file,
const char *argv[],
const char *envp[]);
92 boost::asio::posix::stream_descriptor &sd, boost::asio::streambuf &buf);
94 boost::asio::posix::stream_descriptor &sd, boost::asio::streambuf &buf,
95 boost::system::error_code ec,
size_t bytes_read);
99 std::string progname_;
106 boost::asio::io_service io_service_;
107 std::thread io_service_thread_;
108 boost::asio::io_service::work io_service_work_;
112 boost::asio::posix::stream_descriptor sd_stdin_;
113 boost::asio::posix::stream_descriptor sd_stdout_;
114 boost::asio::posix::stream_descriptor sd_stderr_;
116 boost::asio::streambuf buf_stdout_;
117 boost::asio::streambuf buf_stderr_;
SubProcess(const char *progname, const char *file, const char *argv[], const char *envp[])
Constructor.
Fawkes library namespace.
boost::asio::posix::stream_descriptor & sd_stdout()
Get stdout stream descriptor.
int pipe_stdout_r() const
Get stdout pipe file descriptor.
void kill(int signum)
Send a signal to the process.
void check_proc()
Check if the process is still alive.
int pipe_stderr_r() const
Get stderr pipe file descriptor.
int pipe_stdin_w() const
Get stdin pipe file descriptor.
boost::asio::posix::stream_descriptor & sd_stderr()
Get stderr stream descriptor.
pid_t pid() const
Get PID of sub-process.
Sub-process execution with stdin/stdout/stderr redirection.
boost::asio::posix::stream_descriptor & sd_stdin()
Get stdin stream descriptor.