Xref: utzoo comp.unix.questions:6853 comp.unix.wizards:8227 Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!oliveb!sun!gorodish!guy From: guy@gorodish.Sun.COM (Guy Harris) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: processes (was Re: Trouble killing processes in SysV/AT) Message-ID: <51899@sun.uucp> Date: 4 May 88 04:51:47 GMT References: <3951@killer.UUCP> <77@lakart.UUCP> Sender: news@sun.uucp Lines: 39 > My process was there, but so were about 40 processes marked STAT == Z, > COMMAND == . Trying to kill -9 these failed, Just as shooting a corpse won't do anything interesting, either. "" 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 */