top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How we can create a zombie process?

+1 vote
381 views
How we can create a zombie process?
posted Jun 21, 2014 by Amit Kumar Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes
 
Best answer

Zombie is a process state where process does not actually exist. It mostly happen when child dies But when

Check the following program

#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main ()
{
  pid_t child_pid;

  child_pid = fork ();
  if (child_pid > 0) { // Parent Process
    sleep (60);
  }
  else {
    exit (0); // Child Process
  }
  return 0;
}

When you run the above program and see the process details after 2-3 second (ps -e -o pid,ppid,stat,cmd) you will see the child process is marked as and its status code is Z, for zombie. Whenever parent process completes the processing and exit then zombie state for the non-existing child process gets cleared automatically.

answer Jun 21, 2014 by Salil Agrawal
0 votes

Follow the few steps to create a zombie process:

  1. Create a child process using fork system call.
  2. Make parent process busy or sleep for some amount of time.
  3. Make sure that child process should not involve in very extensive processing. I mean to say just put few simple statement and let the child process exit.
  4. Since the parent process is busy or in sleep mode and child process has been already finished its job and exited. We say child process is zombie now since parent has not yet received its's exit status and its entry still exists in process table.

Please correct me if I have missed something.

answer Jun 21, 2014 by Harshita
...