How to clear defunct processes??

How to find out and clear the 'defunct' processes at OS and DB level ..??

It's not the system that's letting them accumulate, it's whatever program creating them that is. They still belong to a living process, one which hasn't called wait() for them. That's a bug.

If you restart that daemon, causing it to quit and reload, those zombie processes will default their ownership back to INIT, which will handle them properly.

You get a defunct process (or zombie) when that process exits and its parent does not gather its exit status (see the man page for the wait() system call). If, and only if, the parent exits before its children's exit status is collected, a system process (usually named init) will gather the exit status of abandoned children.

This is the way it works on any UNIX or Linux system, not just HP/UX.

PS: you cannot use

kill -9

on a defunct (zombie) process, because the process is already dead.

The name zombie comes from those cheap 1960's movies like 'Day of the Dead' - except in those movies you could apparently 'kill' those zombies.... you cannot kill something that is already dead in UNIX, it ain't the movies.

3 Likes

I have a question: You mentioned that the zombie process is already dead. But this process entry remains in the process table. I read somewhere that the problem would grow serious under heavier loads and OS may run out of Process ID numbers! Is this situation possible or does init invokes wait system call all the time and reap any zombies?

Zombies remain in the process table for a reason: There's still information there about how the program quit, which their parent is supposed to get via the wait() or other related calls. Once it does, they're deleted from the table.

init can't wait for processes that don't belong to it. If it did, that could cause problems with processes that were handling their children -- if init handles the dead process first for whatever reason, the proper parent will be stuck waiting for it.

So, only the owner of a process is allowed to wait() for it.

So a process that accumulates an endless amount of zombies is a serious problem. There may be limits in place preventing one user from running too many simultaneous processes, but often these limits haven't been specified for daemons. It's possible for the process table to be filled up, yes.

The proper way to deal with zombies is to fix the bug in the program that's allowing zombies to accumulate. The short-term solution is to kill their parent -- all the zombies will default back to init, which will clean them up.

1 Like

In HP-UX zombie processes which are waiting for a hardware resource will not die without a reboot.

Can you post an example process tree?
How many zombie processes do you have on a bad day? Do they ever disappear without a reboot?
What database engine are you using, and do you have a simple explanation for the zombie processes (like users disconnecting untidily)?

1 Like