// can run this zombie process as the "sole" process inside of a container // (bash might be reaping children) // even though 30 zombies don't have parents, after 5 minutes the container // exist and there are no zombies in sight at the host level process tables #include #include #include int main () { int i; pid_t parent_pid; pid_t child_pid; // spawn 30 zombie grand children for (i=30; i>0; i--) { parent_pid = fork(); if (parent_pid > 0) { // run a child child_pid = fork (); if (child_pid > 0) { // child sleep (60); } else { // parent exit (0); } } else { // grand parent (actual exec) just sleeps for 5 min // doesn't waitpid or reaps anything if (i == 1) { sleep (300); } } } return 0; }