<defunct> processes (was Re: Trouble killing processes in SysV/AT)
Guy Harris
guy at gorodish.Sun.COM
Wed May 4 14:51:47 AEST 1988
> My process was there, but so were about 40 processes marked STAT == Z,
> COMMAND == <defunct>. Trying to kill -9 these failed,
Just as shooting a corpse won't do anything interesting, either.
"<defunct>" means "defunct." Those processes have already been killed;
however, a dead process remains around in "zombie" form (hence the "Z") until
the parent process does a "wait()" or variant thereof to pick up and dispose of
the corpse.
> I got lucky in comparison to Mr. Paul - at least these went away when the
> parent exited.
When the parent exits, "init" gets custody of the body and disposes of it
rather quickly.
> As an interesting aside, I was running TT == 0 (/dev/tty0), but the
> controlling TT of these defunct processes was drifting all over hell's
> half acre: TT == co, then TT == h1, then TT == dx - all for the same process!
Long-standing 4BSD "ps" bug. The controlling tty information comes from the U
area of the process; however, zombies don't have U areas. However, "ps"
doesn't understand the connection between these two facts; it still tries to
extract the controlling tty from its U-area buffer. This means it picks up the
controlling tty of the last process whose U area it read.
The correct fix is to change the code at the beginning of "save()" from:
if (mproc->p_stat != SZOMB && getu() == 0)
return;
ttyp = gettty();
to something like:
if (mproc->p_stat != SZOMB) {
if (getu() == 0)
return;
ttyp = gettty();
} else
ttyp = "?"; /* zombies are not attached to terminals */
More information about the Comp.unix.questions
mailing list