ASSA::ForkList Class Reference

ForkList is a singleton class that keeps a list of all forked children. More...

#include <Fork.h>

Inheritance diagram for ASSA::ForkList:

Inheritance graph
[legend]
Collaboration diagram for ASSA::ForkList:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ForkList ()
 Constructor.
 ~ForkList ()
 Destructor. Wipe out childer based on their state.

Public Attributes

list< fnode_t * > m_list
 List of children's data structures.

Detailed Description

ForkList is a singleton class that keeps a list of all forked children.

Its task is on process exit, for each child forked, either terminate it with SIGTERM or wait for its exit. In any case, child's exit status is collected thus avoiding zombie processes.

Definition at line 231 of file Fork.h.


Constructor & Destructor Documentation

ASSA::ForkList::ForkList  )  [inline]
 

Constructor.

Definition at line 235 of file Fork.h.

References ASSA::FORK, and trace_with_mask.

00235 { trace_with_mask("ForkList::ForkList",FORK); }

ForkList::~ForkList  ) 
 

Destructor. Wipe out childer based on their state.

Definition at line 189 of file Fork.cpp.

References ASSA::FORK, m_list, and trace_with_mask.

00190 {
00191     trace_with_mask("ForkList::~ForkList",FORK);
00192 
00193     list<fnode_t* >::iterator i;
00194     pid_t pid;
00195 
00196     // Go through the list and send SIGTERM to those children
00197     // whose flags were set at fork time.
00198 
00199     for (i = m_list.begin(); i != m_list.end(); i++) {
00200         if ((*i)->needKill()) {
00201             ::kill((*i)->getPID(), SIGTERM);
00202         }
00203     }
00204     // Wait for all children to exit.
00205 
00206     while ( ! m_list.empty() ) { // wait for child to exit
00207         pid = ::wait(NULL);
00208         if ( pid < 0 ) { // error on wait
00209             EL((ASSAERR,"Error on wait()\n"));
00210             exit (EXIT_FAILURE);
00211         }
00212         // Search for child through the list by its pid.
00213         // If found, remove it from list and release memory.
00214         
00215         list<fnode_t* >::iterator j;
00216         
00217         for (j = m_list.begin(); j != m_list.end(); j++) {
00218             if ((*j)->getPID() == pid) {
00219                 fnode_t* ep = *j;
00220                 m_list.erase(j);
00221                 delete ep;
00222                 break;
00223             }
00224         }
00225     }
00226 }


Member Data Documentation

list< fnode_t* > ASSA::ForkList::m_list
 

List of children's data structures.

Definition at line 241 of file Fork.h.

Referenced by ~ForkList().


The documentation for this class was generated from the following files:
Generated on Sun Aug 13 15:08:19 2006 for libassa by  doxygen 1.4.6