Go to the documentation of this file.
18 #include <sys/types.h>
22 # include <sys/wait.h>
35 #include <sys/resource.h>
37 wait4(pid_t pid,
int *statusp,
int options,
struct rusage *rusage);
153 #endif // !defined(WIN32)
170 static int fork_exec (
const string& cmd_,
173 bool ignore_output_ =
false);
189 #endif // !defined(WIN32)
bool needKill() const
Retrieve kill flag.
list< fnode_t * > m_list
List of children's data structures.
SigHandler m_local_sh
Local signal handler.
Fork class is a simple wrapper around C library function fork(). Main advantage of using Fork over fo...
static int fork_exec(const string &cmd_, const string &args_, wait4status_t wait_for_completion_, bool ignore_output_=false)
Execute an external command.
@ FORK
Class Fork messages
pid_t getPID() const
Retrieve child pid.
@ COLLECT_STATUS
Wait for child to complete and collect its exit status.
Fork::state_t m_state
Child state {kill, wait}.
fnode_t(pid_t pid_, Fork::state_t state_)
Constructor.
bool isChild() const
Test whether we are in child section of the code.
bool isParent() const
Test whether we are in parent section of the code.
@ WAIT_ON_EXIT
Wait for all children to exit.
~ForkList()
Destructor. Wipe out childer based on their state.
int handle_signal(int signum_)
Signal handler callback.
ForkList is a singleton class that keeps a list of all forked children.
@ IGNORE_STATUS
Don't wait for child to complete.
int get_exit_status() const
Retrieve exit status of a child process if the constructor's parameter catch_status_ was set to TRUE.
ChildStatusHandler m_chstath
Handler to catch Child's status.
@ KILL_ON_EXIT
Kill all childer on exit.
SigAction m_old_disp
Old signal disposition.
Fork(state_t exit_action_=WAIT_ON_EXIT, wait4status_t catch_status_=COLLECT_STATUS)
Fork the current process in two immediately.
pid_t getChildPID() const
Retrieve child process id.
#define trace_with_mask(s, m)
@ LEAVE_ALONE
Ignore all running children on exit.