\hypertarget{group__selfpipe}{
\section{selfpipe: Safe child exit management.}
\label{group__selfpipe}\index{selfpipe: Safe child exit management.@{selfpipe: Safe child exit management.}}
}
\subsection*{Functions}
\begin{CompactItemize}
\item 
int \hyperlink{group__selfpipe_gc4db7cc1f56335163a95ce02ebe7303a}{selfpipe\_\-init} (void)
\item 
void \hyperlink{group__selfpipe_gb1d668ed406e732dec94a07369ca3934}{selfpipe\_\-close} (void)
\item 
void \hyperlink{group__selfpipe_g7b26bb58c5dca4e851f1ad4426f6a66d}{selfpipe\_\-catch\_\-signal} (int)
\end{CompactItemize}


\subsection{Function Documentation}
\hypertarget{group__selfpipe_g7b26bb58c5dca4e851f1ad4426f6a66d}{
\index{selfpipe@{selfpipe}!selfpipe_catch_signal@{selfpipe\_\-catch\_\-signal}}
\index{selfpipe_catch_signal@{selfpipe\_\-catch\_\-signal}!selfpipe@{selfpipe}}
\subsubsection[selfpipe\_\-catch\_\-signal]{\setlength{\rightskip}{0pt plus 5cm}void selfpipe\_\-catch\_\-signal (int {\em signal})}}
\label{group__selfpipe_g7b26bb58c5dca4e851f1ad4426f6a66d}


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

This routine can be used with sig\_\-$\ast$\_\-catch() to send other signals through the self-pipe. \hypertarget{group__selfpipe_gb1d668ed406e732dec94a07369ca3934}{
\index{selfpipe@{selfpipe}!selfpipe_close@{selfpipe\_\-close}}
\index{selfpipe_close@{selfpipe\_\-close}!selfpipe@{selfpipe}}
\subsubsection[selfpipe\_\-close]{\setlength{\rightskip}{0pt plus 5cm}void selfpipe\_\-close (void)}}
\label{group__selfpipe_gb1d668ed406e732dec94a07369ca3934}


Shut down the self-pipe. \hypertarget{group__selfpipe_gc4db7cc1f56335163a95ce02ebe7303a}{
\index{selfpipe@{selfpipe}!selfpipe_init@{selfpipe\_\-init}}
\index{selfpipe_init@{selfpipe\_\-init}!selfpipe@{selfpipe}}
\subsubsection[selfpipe\_\-init]{\setlength{\rightskip}{0pt plus 5cm}int selfpipe\_\-init (void)}}
\label{group__selfpipe_gc4db7cc1f56335163a95ce02ebe7303a}


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 {\tt poll} or {\tt select} to determine when it is readable. When it becomes readable, read the data written to it (and throw it away), and use {\tt wait} or equivalent to catch the {\tt exit} value from the child process(es).

\begin{Desc}
\item[Returns:]-1 if an error occurred, otherwise the return value is the file descriptor opened for reading. \end{Desc}
