zombifier.c

test case – run and check "ps axl | fgrep zombifier" - matthiasr, 04/17/2012 01:11 PM

Download (401 Bytes)

 
1
#include <stdlib.h>
2
#include <unistd.h>
3
#include <signal.h>
4

    
5
int main(int argc, char **argv) {
6
    int pid = 0;
7
    int i;
8
    for( i = 300; i>0; i-- ) {
9
        signal(SIGCHLD, SIG_IGN);
10
        pid = fork();
11
        switch(pid) {
12
            case -1:
13
                exit(1);
14
            case 0:
15
                exit(2);
16
            default:
17
                sleep(1);
18
        }
19
    }
20
    exit(0);
21
}