Write a C program to create a Zombie process.

AIM :

Write  a C program to create a Zombie process.

Program:

#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main ()
{
  int pid_t child_pid;
  child_pid = fork ();
  if (child_pid > 0) {
    sleep (60);
  }
  else {
    exit (0);
  }
  return 0;
}

Output:

guest-glcbIs@ubuntu:~$gcc  zombie.c
guest-glcbIs@ubuntu:~$./a.out
Then command prompt will wait for some time(60 sec) and  then again command prompt will appear later.