multi_sigchld


The following program demonstrates one way that a long-running process may choose to asynchronously reap its children: by calling waitpid within a signal handler. If a process has a signal handler registered for SIGCHLD, then the kernel will deliver the parent this signal whenever one if its children terminates. Note that since the kernel does not queue traditional signals, we must call waitpid in a loop to ensure that there is not a race condition when reaping children.

multi_sigchld.c