Loading...
Searching...
No Matches
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:

## 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.

## Additional Inherited Members

Static Public Member Functions inherited from ASSA::Singleton< ForkList >
static ForkList * | get_instance ()
| Return an instance of templated class T.
Protected Member Functions inherited from ASSA::Singleton< ForkList >
| Singleton ()
| Protected Constructor.
virtual | ~Singleton ()
| Virtual Destructor.

## 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

## ForkList()

ASSA::ForkList::ForkList | ( |  | ) |

inline

Constructor.

Definition at line 235 of file Fork.h.

{ trace_with_mask("ForkList::ForkList",FORK); }
trace_with_mask
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Definition Logger.h:437
ASSA::FORK
@ FORK
Class Fork messages
Definition LogMask.h:47

References ASSA::FORK, and trace_with_mask.

## ~ForkList()

ForkList::~ForkList | ( |  | ) |

Destructor. Wipe out childer based on their state.

Definition at line 187 of file Fork.cpp.

{
trace_with_mask("ForkList::~ForkList",FORK);
list<fnode_t* >::iterator i;
pid_t pid;
// Go through the list and send SIGTERM to those children
// whose flags were set at fork time.
for (i = m_list.begin(); i != m_list.end(); i++) {
if ((*i)->needKill()) {
::kill((*i)->getPID(), SIGTERM);
}
}
// Wait for all children to exit.
while ( ! m_list.empty() ) { // wait for child to exit
pid = ::wait(NULL);
if ( pid < 0 ) { // error on wait
EL((ASSAERR,"Error on wait()\n"));
exit (EXIT_FAILURE);
}
// Search for child through the list by its pid.
// If found, remove it from list and release memory.
list<fnode_t* >::iterator j;
for (j = m_list.begin(); j != m_list.end(); j++) {
if ((*j)->getPID() == pid) {
fnode_t* ep = *j;
m_list.erase(j);
delete ep;
break;
}
}
}
}
EL
#define EL(X)
A macro for writing error message to the Logger.
Definition Logger.h:285
ASSA::AutoPtrRef
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
ASSA::ForkList::m_list
list< fnode_t * > m_list
List of children's data structures.
Definition Fork.h:241
ASSA::fnode_t
forknode_t class.
Definition Fork.h:195
ASSA::ASSAERR
@ ASSAERR
ASSA and system errors
Definition LogMask.h:34

References ASSA::ASSAERR, EL, ASSA::FORK, m_list, and trace_with_mask.

## Member Data Documentation

## m_list

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:

- Fork.h
- Fork.cpp