Re: Destroying processes

From: Richard B. Johnson (
Date: Wed Dec 11 2002 - 14:24:17 EST

On Wed, 11 Dec 2002, Justin Hibbits wrote:

> Hey 00ber-geeks,
> I'm not subscribed (yet....still too lazy to subscribe ;P ), but I have a
> question and/or suggestion.
> Is there a system call that would destroy a process? Sometimes I end up with
> zombie processes, other times I end up with a process attaching to a device
> driver, and hanging, so I want to be able to completely destroy the
> process...image, file handle, driver hooks, everything. If there isn't one,
> and noone wants to do it, I'll gladly do it (may take a few weeks tho). I just
> don't wanna do what someone else has already done.
> Thanks,
> Justin Hibbits

A process gets destroyed when it calls exit() (actually sys_exit()
in the kernel). However, in Unix/Linux machines, it will wait until
somebody executes wait(), wait3(), or similar procedures to get the
return status of the task. A task that is waiting to be "reaped"
in this manner is called a zombie task and it shows up in `ps` with
a state of "Z".

If you have zombie tasks, they are caused by incorrectly written
programs that fork() child tasks without either setting up a signal
handler for SIGCHLD or, at least executing a wait() to get the
return status. The zombie must be reaped by its parent. This means
that if the parent task didn't do this, or no longer exists, the
zombie will remain until all possible parents (parents of parents)
exit. In that case, the parent of a parents, "init" will (should)
reap the status of the child and throw it away.

So, if you run programs that create zombies, the zombies should
go away as soon as you log-off. If you are running from X-Windows,
you may need to get out of X completely. If the zombies don't go away,
you have a broken `init` which should be replaced. You need to add
the proper code to programs that execute fork(), so that they don't
generate zombies.

Programs that exit always end up closing all file-handles. The kernel
does this automatically. Therefore, there should never be any hung
processes attaching a device driver unless there are errors inside
the device driver. In that case, you need to fix the device driver.

Dick Johnson
Penguin : Linux version 2.4.18 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Sun Dec 15 2002 - 22:00:22 EST