#include #include #include int main(int argc, char **argv) { const pid_t pid = fork(); if (pid < 0) { /* Parent could not create child. */ perror(argv[0]); return EXIT_FAILURE; } if (pid == 0) { /* Child immediately turns itself into a zombie. */ return EXIT_SUCCESS; } sleep(3); /* Parent waits for child to turn itself into a zombie. */ system("/usr/ucb/ps -gl"); /* Parent photographs the zombie child. */ /* Parent gets rid of the zombie child. */ if (wait(NULL) < 0) { perror(argv[0]); return EXIT_FAILURE; } return EXIT_SUCCESS; }