#include <Fork.h>
Inheritance diagram for ASSA::ForkList:
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. |
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 220 of file Fork.h.
|
Constructor.
Definition at line 224 of file Fork.h. References ASSA::FORK, and trace_with_mask. 00224 { trace_with_mask("ForkList::ForkList",FORK); }
|
|
Destructor. Wipe out childer based on their state.
Definition at line 175 of file Fork.cpp. References EL, ASSA::ERROR, ASSA::FORK, m_list, and trace_with_mask. 00176 { 00177 trace_with_mask("ForkList::~ForkList",FORK); 00178 00179 list<fnode_t* >::iterator i; 00180 pid_t pid; 00181 00182 // Go through the list and send SIGTERM to those children 00183 // whose flags were set at fork time. 00184 00185 for (i = m_list.begin(); i != m_list.end(); i++) { 00186 if ((*i)->needKill()) { 00187 ::kill((*i)->getPID(), SIGTERM); 00188 } 00189 } 00190 // Wait for all children to exit. 00191 00192 while ( ! m_list.empty() ) { // wait for child to exit 00193 pid = ::wait(NULL); 00194 if ( pid < 0 ) { // error on wait 00195 EL((ERROR,"Error on wait()\n")); 00196 exit (EXIT_FAILURE); 00197 } 00198 // Search for child through the list by its pid. 00199 // If found, remove it from list and release memory. 00200 00201 list<fnode_t* >::iterator j; 00202 00203 for (j = m_list.begin(); j != m_list.end(); j++) { 00204 if ((*j)->getPID() == pid) { 00205 fnode_t* ep = *j; 00206 m_list.erase(j); 00207 delete ep; 00208 break; 00209 } 00210 } 00211 } 00212 }
|
|
List of children's data structures.
Definition at line 230 of file Fork.h. Referenced by ~ForkList(). |