Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Examples  

SUEChildHandler Class Reference

SUE Child (SIGNCHLD on particular process) Handler. More...

#include <sue_wait.hpp>

List of all members.

Public Methods

 SUEChildHandler (pid_t a_pid, SUEChildWaitAgent *a_agent)
 Constructor.

virtual ~SUEChildHandler ()
 Destructor.

virtual void ChildHandle ()
 Handling method.


Protected Methods

pid_t GetPid () const
bool IfExited () const
 Did the process exit?

int ExitCode () const
 What was the process' exit code?

bool IfSignaled () const
 What was the process killed with a signal?

int TermSig () const
 What was the process' termination signal?


Detailed Description

SUE Child (SIGNCHLD on particular process) Handler.

This class allows to handle the event 'particular child process finished'. You need to create a derived class with the ChildHandle() method overriden to implement your custom handling. You also can use SUEChildHandle as is if you only need to get rid of zombies and no special hanling is required.

Note:
You need to have an object of SUEChildWaitAgent class in your program in order this mechanism to work.
Objects of SUEChildHandler class are 'single-use only'. You can just create your object with operator new, and all the care is then taken by SUEChildWaitAgent. The object is deleted immediately after the ChildHandle() method is called.
Warning:
Never try to create an object of SUEChildHandler anyhow but with operator new! It will not work.
If you pass an invalid pid, the mechanism will throw an exception once your main process get a SIGCHLD.
Examples:

children.cpp.


Constructor & Destructor Documentation

SUEChildHandler::SUEChildHandler pid_t    a_pid,
SUEChildWaitAgent   a_agent
 

Constructor.

virtual SUEChildHandler::~SUEChildHandler   [inline, virtual]
 

Destructor.


Member Function Documentation

virtual void SUEChildHandler::ChildHandle   [inline, virtual]
 

Handling method.

Override this in your derived class to implement your custom functionality. Use GetPid(), IfExited(), ExitCode() and IfSignaled() methods to analyse the situation.

Note:
The default is to do nothing, which also makes sence because the agent does waitpid(2) on the process thus removing zombie process as approproate.
Examples:
children.cpp.

int SUEChildHandler::ExitCode   [protected]
 

What was the process' exit code?

Only useful from within ChildHandle(), and only if IfExited() returns true.

Examples:
children.cpp.

pid_t SUEChildHandler::GetPid   const [inline, protected]
 

Examples:
children.cpp.

bool SUEChildHandler::IfExited   [protected]
 

Did the process exit?

Only useful from within ChildHandle()

Examples:
children.cpp.

bool SUEChildHandler::IfSignaled   [protected]
 

What was the process killed with a signal?

Only useful from within ChildHandle()

int SUEChildHandler::TermSig   [protected]
 

What was the process' termination signal?

Only useful from within ChildHandle(), and only if IfSignaled() returns true.


The documentation for this class was generated from the following file:
Generated on Fri Feb 27 13:17:26 2004 for SUE Library by doxygen1.2.18