[cw] /* * Listing 3: * Explicitly reaping the child: * Ivan Griffin (ivan.griffin@ul.ie) */ #include #include #include void ReapChild(int pid); struct sigaction reapAction = { ReapChild, /* SIG_DFL for default, SIG_IGN to ignore, * else handler */ 0, /* mask of signals to block during execution * of handler */ SA_RESTART, /* don't reset to default handler after signal * is raised */ NULL /* Not used - should be NULL */ }; int main(int argc, char *argv[]) { /* * somewhere in main code */ sigaction(SIGCHLD, &reapAction, NULL); /* * rest of code */ return 0; } void ReapChild(int pid) { int status; wait(&status); } [ecw] Listing 3. Explicitly reaping the (dead) child process.