Last active
August 29, 2015 13:58
-
-
Save NeoCat/9982700 to your computer and use it in GitHub Desktop.
Avoid zombie processes on Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Avoid creation of zombie process by child processes. | |
* build: gcc -O2 ignchld.c -o ignchld | |
* usage: ignchld bad-command-that-creates-zombie-processes [args ...] | |
*/ | |
#include <signal.h> | |
#include <string.h> | |
#include <unistd.h> | |
int main(int argc, char *argv[]) | |
{ | |
signal(SIGCHLD, SIG_IGN); | |
strncpy(argv[0], "env", strlen(argv[0])); | |
execv("/usr/bin/env", argv); | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment