How do you create a zombie process?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How do you create a zombie process?
# 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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

How to get rid of zombie process?

Hi, How to get rid of Zombie Process, Kill -9 PID does not seem to be permanent solution, your help will be Appreciated. Thanks (11 Replies)
Discussion started by: szs
11 Replies

2. AIX

Catch Zombie Process

Hi All, Anyone have any shell script to capture the zombie process, as according to the support they need the real time zombie PID, they only provide the kdb (0) > p* |grep -i defunct (0) > p * | grep <hex pid> But this is doesn't seem easy to catch the zombie as it is not always... (1 Reply)
Discussion started by: ckwan
1 Replies

3. UNIX for Advanced & Expert Users

Zombie process

What is the overhead associated with zombie process?Is it running out of process-ID?:confused: Since some information is stored in process table.. Thanks in Advance (4 Replies)
Discussion started by: jois
4 Replies

4. AIX

zombie process

Is there an equivilant to the preap command in AIX that would allow me to get rid of a zombie process. I am new to AIX, moving over from Solaris and in the past I have been able to preap the pid on the defunct process to clean them up. I have looked around and the best I can see is that it may... (3 Replies)
Discussion started by: sboots
3 Replies

5. Solaris

zombie process

dear friends, in an interview they asked me what is zombie process. how we can identifying these process.if can you kill all zombie process. (8 Replies)
Discussion started by: sijocg
8 Replies

6. Shell Programming and Scripting

Zombie process

Hi I need help because I don't know if it is possible to add a find inside a cat. like I have a file with the pid of the process that use to became zombie. And I have the same pid stored in the var (pid1) now, I have no clue how to check if the the find finds the pid or even if it's... (2 Replies)
Discussion started by: ruben.rodrigues
2 Replies

7. UNIX for Dummies Questions & Answers

Re: How do I recognize a zombie process?

Hey Guys, I am not really new to Unix/Linux however I was never taught how to spot a zombie process. I used top to check out the processes I was running and how the resources were looking and in the upper right it said 1 zombie, I have attached a jpeg of it. Thank you in advance for your... (4 Replies)
Discussion started by: pikecoguy
4 Replies

8. Linux

zombie process

Hi What is the command to find only the zombie processes?? How to write the code in C to fetch the no. of zombie processes?? Thanx (5 Replies)
Discussion started by: jeenat
5 Replies

9. UNIX for Advanced & Expert Users

Zombie process

I would like to create a zombie process so that I can test monitoring software functionality. Any techniques? (2 Replies)
Discussion started by: swhitney
2 Replies

10. UNIX for Dummies Questions & Answers

Zombie process

How do i kill a zombie process. Is it that only root can kill a zombie process. (8 Replies)
Discussion started by: orca
8 Replies
Login or Register to Ask a Question