How do you create a zombie process?

Tags
beginners

 

 
Thread Tools Search this Thread
# 1  
Old 02-13-2009
How do you create a zombie process?

I'm very new to UNIX, so I need some help please.

How do I create a zombie process with just basic UNIX commands (no script, C, PERL, etc)? Please give an example. Thanks.
# 2  
Old 02-13-2009
you don't create zombie processes. zombie is a process state. the process does not actually exist. Read up on what a zombie process is and then you will understand how to do it. I don't understand why a UNIX newbie would be trying to do this though.
# 3  
Old 02-13-2009
I know zombie is a process state, but I'm trying to create one so I can see how it looks like.
# 4  
Old 02-15-2009
this sounds cool.
so teiji.
did u get a chance to see a ZOMBIE process?
If yes, please reply me your work and if possible an example !!!
# 5  
Old 02-16-2009
Hello,

A ZOMBIE program is NOT something you want in your system.

It is a process that crashed and which is robbing memory space and/or cpu cycles.
They are detached from any terminals or processes that lauched it in the first place and are hard to kill. sometime only a reboot can get rid of it.

However, if you want to launch a program in the background there is 2 options to do so.

A) /usr/bin/your program &
B) nohup /usr/bin/your program

The differences lies in what your program do when you log out.
A) The program terminates upon login out
B) The program keep on running and only a kill or fuser command will stop it.
# 6  
Old 02-16-2009
If you're curious and want to see how a zombie looks like you can create a zombie process with this c program:

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

int main ()
{
  pid_t child_pid;

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

Save it as zombie.c, compile it with:

Code:
cc zombie.c -o zombie

and run it with:

Code:
./zombie

Now check the output of this command (within 1 minute) in another window:

Code:
ps -e -o pid,ppid,stat,cmd

The child process is marked as <defunct>, and its status code is Z, for zombie.

When the program exits, the child process is inherited by init. This process should cleans up the zombie proces automatically.


Regards
# 7  
Old 02-16-2009
Quote:
Originally Posted by yvant
It is a process that crashed and which is robbing memory space and/or cpu cycles.
this is an incorrect statement. a zombie process is not taking up system resources. the process does not actually exist anymore. the entry is left in the process table until the parent reads its exit status. The only resource used is the slot in the process table.
 

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to get rid of zombie process? szs Red Hat 11 06-06-2013 05:34 PM
Catch Zombie Process ckwan AIX 1 11-03-2011 05:36 AM
Zombie process jois UNIX for Advanced & Expert Users 4 06-07-2011 11:54 AM
Zombie process question kingpin007 UNIX for Dummies Questions & Answers 6 04-19-2011 01:49 PM
How to Kill Zombie Process fredginting Solaris 10 05-08-2010 06:18 PM
zombie process sboots AIX 3 04-07-2010 07:53 AM
zombie process sijocg Solaris 8 07-19-2009 09:42 PM
Zombie process ruben.rodrigues Shell Programming and Scripting 2 03-11-2009 12:13 PM
How to kill zombie process will_mike Linux 1 09-04-2008 10:29 PM
Re: How do I recognize a zombie process? pikecoguy UNIX for Dummies Questions & Answers 4 08-23-2008 05:29 AM
zombie process jeenat Linux 5 03-28-2008 08:36 AM
how to handle a zombie process mridula Programming 1 12-06-2005 05:47 PM
zombie daemon process!! rish2005 UNIX for Advanced & Expert Users 1 11-25-2005 09:59 AM
Zombie process swhitney UNIX for Advanced & Expert Users 2 10-22-2004 06:12 PM
Zombie process orca UNIX for Dummies Questions & Answers 8 04-26-2002 03:54 PM
All times are GMT -4. The time now is 02:53 PM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.