// A C program to demonstrate Zombie Process. // Child becomes Zombie as parent is sleeping // when child process exits. #include #include #include #include int main() { // Fork returns process id // in parent process pid_t child_pid = fork(); // Parent process if (child_pid > 0) { printf("\n In the parent process. Waiting for 60 seconds.\n "); fflush(stdout); sleep(60); } // Child process else { printf("\n In the child process. Waiting for 30 seconds. \n"); fflush(stdout); sleep(30); printf("\n Child process exiting. Becomes a zombie for the next 30 seconds. \n"); fflush(stdout); } return 0; }