#include <childprocess.h>
Public Member Functions | |
ChildProcess () | |
virtual | ~ChildProcess () |
pid_t | fork () |
For a subprocess to run proc. | |
pid_t | forkAndRedirect (int *stdinfd=0, int *stdoutfd=0, int *stderrfd=0) |
Fork a subprocess to run proc. | |
pid_t | pid () const |
Get the pid of the child process or (pid_t)-1 if no child is running. | |
int | wait () |
Wait for the child to finish, returing its exit status. | |
bool | running () |
int | exitStatus () |
void | waitForSuccess () |
int | wait (struct rusage *ru) |
Wait for the child to finish, returing its exit status and storing resource usage informations in `ru'. | |
void | kill (int signal) |
Send the given signal to the process. | |
Protected Member Functions | |
void | waitError () |
virtual int | main ()=0 |
Main function to be called in the child process after it has forked. | |
Protected Attributes | |
pid_t | _pid |
int | m_status |
wibble::sys::ChildProcess::ChildProcess | ( | ) | [inline] |
virtual wibble::sys::ChildProcess::~ChildProcess | ( | ) | [inline, virtual] |
int wibble::sys::ChildProcess::exitStatus | ( | ) |
pid_t wibble::sys::ChildProcess::fork | ( | ) |
For a subprocess to run proc.
References _pid, main(), and pid().
Referenced by forkAndRedirect(), and TestChildprocess::kill().
pid_t wibble::sys::ChildProcess::forkAndRedirect | ( | int * | stdinfd = 0 , |
|
int * | stdoutfd = 0 , |
|||
int * | stderrfd = 0 | |||
) |
Fork a subprocess to run proc.
If one of the std*fd variables is non-null, create a pipe connected to the corresponding file descriptor of the child process and store the parent end in the std*fd variable.
References _pid, fork(), kill(), main(), and pid().
Referenced by TestChildprocess::output(), TestChildprocess::redirect(), and TestChildprocess::shellCommand().
void wibble::sys::ChildProcess::kill | ( | int | signal | ) |
Send the given signal to the process.
References _pid.
Referenced by forkAndRedirect(), and TestChildprocess::kill().
virtual int wibble::sys::ChildProcess::main | ( | ) | [protected, pure virtual] |
Main function to be called in the child process after it has forked.
Implemented in EndlessChild, TestChild, and wibble::sys::Exec.
Referenced by fork(), and forkAndRedirect().
pid_t wibble::sys::ChildProcess::pid | ( | ) | const [inline] |
Get the pid of the child process or (pid_t)-1 if no child is running.
References _pid.
Referenced by fork(), and forkAndRedirect().
bool wibble::sys::ChildProcess::running | ( | ) |
References _pid, m_status, and waitError().
int wibble::sys::ChildProcess::wait | ( | struct rusage * | ru | ) |
Wait for the child to finish, returing its exit status and storing resource usage informations in `ru'.
Return -1 if no child is running. TODO: gracefully handle the EINTR error code
References _pid, m_status, and waitError().
int wibble::sys::ChildProcess::wait | ( | ) |
Wait for the child to finish, returing its exit status.
Return -1 if no child is running. TODO: gracefully handle the EINTR error code
References _pid, m_status, and waitError().
Referenced by TestChildprocess::kill(), TestChildprocess::output(), TestChildprocess::redirect(), TestChildprocess::shellCommand(), and waitForSuccess().
void wibble::sys::ChildProcess::waitForSuccess | ( | ) |
References wait().
pid_t wibble::sys::ChildProcess::_pid [protected] |
int wibble::sys::ChildProcess::m_status [protected] |