// A C program to demonstrate Zombie Process. #include #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 child process to complete.\n "); wait((int *)0); fflush(stdout); printf("\n In the parent process. Waiting for 60 seconds.\n "); 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.\n"); fflush(stdout); } return 0; }