Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Related Pages

selfpipe: Safe child exit management.


Functions

int selfpipe_init (void)
 Set up a self-pipe for catching child exit events.

void selfpipe_close (void)
 Shut down the self-pipe.

void selfpipe_catch_signal (int signal)
 Catch a signal and write it to the self-pipe.


Function Documentation

void selfpipe_catch_signal int  signal  ) 
 

Catch a signal and write it to the self-pipe.

This routine can be used with sig_*_catch() to send other signals through the self-pipe.

int selfpipe_init void   ) 
 

Set up a self-pipe for catching child exit events.

This function opens up a pipe within the program used to safely handle exiting child processes. Every time a child exits, a single byte is written to the pipe. The resulting file descriptor is statically assigned, so do not call this function more than once within a single program. The file descriptor is set to non-blocking mode to prevent blocking when reading from it.

To use the file descriptor, use either poll or select to determine when it is readable. When it becomes readable, read the data written to it (and throw it away), and use wait or equivalent to catch the exit value from the child process(es).

Returns:
-1 if an error occurred, otherwise the return value is the file descriptor opened for reading.


Generated on Mon Dec 1 13:28:06 2003 for bglibs by doxygen 1.3.3