Created
April 17, 2012 17:45
-
-
Save matthiasr/2407731 to your computer and use it in GitHub Desktop.
shouldn't create zombies
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
| #include <stdlib.h> | |
| #include <unistd.h> | |
| #include <signal.h> | |
| int main(int argc, char **argv) { | |
| int pid = 0; | |
| int i; | |
| for( i = 300; i>0; i-- ) { | |
| signal(SIGCHLD, SIG_IGN); | |
| pid = fork(); | |
| switch(pid) { | |
| case -1: | |
| exit(1); | |
| case 0: | |
| exit(2); | |
| default: | |
| sleep(1); | |
| } | |
| } | |
| exit(0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment