Fawkes API
Fawkes Development Version
|
Sub-process execution with stdin/stdout/stderr redirection. More...
#include <>>
Public Member Functions | |
SubProcess (const char *progname, const char *file, const char *argv[], const char *envp[]) | |
Constructor. More... | |
SubProcess (const char *progname, const char *file, const char *argv[], const char *envp[], fawkes::Logger *logger) | |
Constructor. More... | |
~SubProcess () | |
Destructor. More... | |
pid_t | pid () const |
Get PID of sub-process. More... | |
int | pipe_stdin_w () const |
Get stdin pipe file descriptor. More... | |
int | pipe_stdout_r () const |
Get stdout pipe file descriptor. More... | |
int | pipe_stderr_r () const |
Get stderr pipe file descriptor. More... | |
boost::asio::posix::stream_descriptor & | sd_stdin () |
Get stdin stream descriptor. More... | |
boost::asio::posix::stream_descriptor & | sd_stdout () |
Get stdout stream descriptor. More... | |
boost::asio::posix::stream_descriptor & | sd_stderr () |
Get stderr stream descriptor. More... | |
void | kill (int signum) |
Send a signal to the process. More... | |
void | check_proc () |
Check if the process is still alive. More... | |
Sub-process execution with stdin/stdout/stderr redirection.
This class executes a sub-process and monitors it and supports redirecting stdout/stderr to a logger.
fawkes::SubProcess::SubProcess | ( | const char * | progname, |
const char * | file, | ||
const char * | argv[], | ||
const char * | envp[] | ||
) |
Constructor.
progname | name of program, component name for logging |
file | file to execute, can be a program in the path or a fully qualified path |
argv | array of arguments for the process, the last element must be NULL |
envp | array of environment variables for the process, the last element must be NULL. Can be NULL to omit. |
fawkes::SubProcess::SubProcess | ( | const char * | progname, |
const char * | file, | ||
const char * | argv[], | ||
const char * | envp[], | ||
fawkes::Logger * | logger | ||
) |
Constructor.
progname | name of program, component name for logging |
file | file to execute, can be a program in the path or a fully qualified path |
argv | array of arguments for the process, the last element must be NULL |
envp | array of environment variables for the process, the last element must be NULL. Can be NULL to omit. |
logger | logger to redirect stdout and stderr to |
fawkes::SubProcess::~SubProcess | ( | ) |
void fawkes::SubProcess::check_proc | ( | ) |
Check if the process is still alive.
Definition at line 240 of file proc.cpp.
References fawkes::Logger::log_error(), and fawkes::Logger::log_warn().
Referenced by OpenPRSThread::loop(), and sd_stderr().
void fawkes::SubProcess::kill | ( | int | signum | ) |
Send a signal to the process.
signum | signal number |
Definition at line 100 of file proc.cpp.
References fawkes::Logger::LL_INFO, fawkes::Logger::LL_WARN, fawkes::Logger::log(), fawkes::Logger::log_error(), pid(), pipe_stderr_r(), pipe_stdin_w(), and pipe_stdout_r().
Referenced by OpenPRSThread::finalize(), sd_stderr(), and ~SubProcess().
|
inline |
|
inline |
Get stderr pipe file descriptor.
Definition at line 64 of file proc.h.
Referenced by kill(), and sd_stderr().
|
inline |
Get stdin pipe file descriptor.
Definition at line 54 of file proc.h.
Referenced by kill(), and sd_stderr().
|
inline |
Get stdout pipe file descriptor.
Definition at line 59 of file proc.h.
Referenced by kill(), and sd_stderr().
|
inline |
Get stderr stream descriptor.
Definition at line 79 of file proc.h.
References check_proc(), kill(), pipe_stderr_r(), pipe_stdin_w(), and pipe_stdout_r().
|
inline |
|
inline |