<defunct> processes

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Robert Ambrose
Date:  
Subject: <defunct> processes
Think of it as the parents not burying their dead children ;-).

Those processes listed as defunct are known as zombies. The purpose of a
zombie process is to hold the status information until the parent process
picks it up. The only resource being used at that point is a slot in the
process table.

FWIW, here's a Q&D zombie maker:

main()
{
        if(fork() == 0)
                exit(255);
        pause();
}


The parent creates a child process. The child process exits, but the
parent never picks up the status via a wait() system call.

Here's an example that doesn't create zombies:

main()
{
        int status;


        if(fork() == 0)
                exit(255);
        wait(&status);
        pause();
}


The bonus question is: in the former example if the parent process is
killed (SIGINT/keyboard interrupt for example), what process picks up the
status from the zombie process?

rna

On Sun, 18 Jan 2004, Michael Havens wrote:

>
> It seems that when I 'ps -e' I have many processes that say 'defunct' next to
> them. I tried killing them with signals 1, 9, and 15 to no avail. I then read
> in the UNIX commands reference section in UNIX Complete that signal 9 leaves
> residue after the kill that must be cleaned up. However, if, as I always
> thought, a reboot is supposed to clean your system why do I have so many
> defunct proccesses? kmail does not always load when I issue the command
> 'kmail' and I am hoping that getting rid of these defunct proccesses will
> alieviate this problem.....
>