Here is a simple recipe that a zombie should create:
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
int main()
{
int pid = fork();
if(pid == 0) {
while(1) pause();
} else {
sleep(1);
kill(pid, SIGKILL);
printf("pid %d should be a zombie\n", pid);
while(1) pause();
}
}
The key is that the parent element, that is, this program, continues to work, but does not execute wait()on a dying child.
- , . , . , - - (, init), , , , .
, , , - . Unix , , . Unix , , , wait.
, : Unix , .