Ejemplo n.º 1
0
//--------------------------------------------------------------------------------------------------
static void OnChildSignal
(
    int sigNum  ///< Id of the signal that fired.
)
//--------------------------------------------------------------------------------------------------
{
    pid_t pid;
    int status;

    LE_INFO("Child signal received.");

    // Get the result code from the child process.
    do
    {
        pid = waitpid(-1, &status, WNOHANG | WUNTRACED | WCONTINUED);
    }
    while (   (pid < 0)
           && (errno == EINTR));

    LE_DEBUG("Server: Child PID %d, exit status: %d.", pid, status);

    // Now, if this is the child process we launched earlier, attempt to call the registered
    // callback.
    if (pid == Current.pid)
    {
        if (Current.handlerPtr != NULL)
        {
            Current.handlerPtr(status, Current.contextPtr);
        }

        Current.pid = -1;
        Current.handlerPtr = NULL;
        Current.contextPtr = NULL;
    }
}