Skip to content

Instantly share code, notes, and snippets.

@zunda
Created August 19, 2011 07:30
Show Gist options
  • Save zunda/1156261 to your computer and use it in GitHub Desktop.
Save zunda/1156261 to your computer and use it in GitHub Desktop.
A code not to create zombies
static void sigchld(int x);
static void
sigchld(int x __attribute__ ((unused)))
{
while(waitpid(-1, NULL, WNOHANG) > 0);
signal(SIGCHLD, sigchld);
}
@zunda
Copy link
Author

zunda commented Aug 19, 2011

fork()する前に親から
signal(SIGCHLD, sigchld);
しておくみたい。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment