# cat zombie.c
#include <stdlib.h>
#include <stdio.h>
int main()
{
pid_t child_pid;
child_pid = fork();
if (child_pid > 0) { // parent
fprintf(stderr, "child : %d\n", child_pid);
pause();
} else if (child_pid == 0) { // child will be zombie
exit(0);
} else {
fprintf(stderr, "fork failed\n");
exit(1);
}
}
# gcc -o zombie zombie.c
# ./zombie
# ps -ef | grep zombie
root 23930 23815 0 16:22 pts/2 00:00:00 ./zombie
root 23931 23930 0 16:22 pts/2 00:00:00 [zombie] <defunct>