Re: unkillable process ?
Re: unkillable process ?
- Subject: Re: unkillable process ?
- From: Philip Parker <email@hidden>
- Date: Mon, 7 Apr 2003 10:23:28 -0700
See my comments interspersed
On Monday, Apr 7, 2003, at 07:38 US/Pacific, Paul Ripke wrote:
On Monday, Apr 7, 2003, at 10:11 Australia/Sydney, Justin Walker wrote:
On Sunday, Apr 6, 2003, at 16:30 US/Pacific, Paul Ripke wrote:
On Sunday, Apr 6, 2003, at 12:01 Australia/Sydney, Jean-Edouard
BABIN wrote:
Justin Walker icrit:
[snip]
Odd. I have one too:
ksh$ ps alx | grep Z
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT
TIME COMMAND
0 509 0 0 0 0 0 0 - Z con-
0:00.00 (scselect)
Just a hunch, but I'd guess that the real PPID isn't zero. I'd say
ps is
reading a struct which has been nulled, and there's another copy of
the
real PPID elsewhere. UTSL...
This was mentioned earlier in this thread. When a process is
inherited by 'init' (PID 1), which happens when the parent process
exits before the child, the child's "parent PID" entry in its proc
table is cleared (init really isn't its parent; the child is just
"attached" to init so that it can be 'reaped'). This is the last
step in cleaning up after a process exit, and is something that a
process can't do for itself (unlike that cute box that, when you turn
it on, has a hand that comes out, turns the switch off, and retreats
back into the box).
This general behavior has been around for a while, I believe [Unix
lore]. I haven't checked other source to be sure.
Yes - but by the same token, I believe it's Unix lore that you can't
have a zombie with init as the parent (even inherited parent)... at
least not for any reasonable duration. I do see it occasionally
on systems that have gone forking mad.
Definitely saying the obvious but ...
If the Zombie is wchan on a resource, and that block is resolved, a PPID
of 1 means that init will reap the process. If it is zero, then noone
will reap it. If it has another PID, then the parent is still around
and has not wait'ed on the process. So a process should have either a
real PPID, or 1, but not 0.
OK, testing, looks like the process struct gets nulled (from a ps point
of view) when the process gets zombie status:
Bad, if you're trying to find out how to fix it. I suspect that the
command information can sometimes be bogus as well.
ksh$ uname -a
Darwin stix-pbg3 6.3 Darwin Kernel Version 6.3: Sat Dec 14 03:11:25
PST 2002; root:xnu/xnu-344.23.obj~4/RELEASE_PPC Power Macintosh
powerpc
ksh$ cat z.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int
main(int argc, char *argv[]) {
pid_t pid;
pid = fork();
if (pid < 0) { /* error */
perror("fork failed");
} else if (pid == 0) { /* child */
exit(0);
} else { /* parent */
for (;;)
sleep(10);
}
return 0;
}
ksh$ cc -o blah blah.c
ksh$ ./blah &
[1] 728
ksh$ ps alx | egrep 'PPID|blah'
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT
TIME COMMAND
0 729 0 0 0 0 0 0 - Z+ con-
0:00.00 (blah)
20008 728 474 0 31 0 1548 292 - S std
0:00.02 ./blah
20008 731 474 0 31 0 1416 308 - S+ std
0:00.02 egrep PPID|blah
This must be a bug, either in the kernel, or ps. Parent is still
around.
Makes hunting down the parent of a zombie a little difficult, may be
worth a bug report. NetBSD doesn't do this:
ksh$ uname -a
NetBSD stix-pc.stix.org.au 1.6P NetBSD 1.6P (STIX-PC) #5: Sun Mar 2
23:28:12 EST 2003
email@hidden:/usr/build/obj/usr/src/sys/arch/i386/
compile/STIX-PC i386
ksh$ ps alx | egrep 'PPID|blah'
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME
COMMAND
20008 23834 1704 0 10 0 12 344 nanoslee S p4 0:00.00
./blah
20008 23835 23834 0 -22 0 0 0 - ZW p4 0:00.00
(blah)
20008 23837 1704 0 28 0 160 540 - S+ p4 0:00.01
egrep PPID|blah
I started digging through xnu source, but it's getting too late
(early?)
for my brain to function too well...
I'd like to do the same, but CVS appears to be down on
anoncvs.opensource.apple.com,
I'm getting "/cvs/Darwin: no such repository"
regards, Philip
--
email: email@hidden #include
<std_disclaimer>
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.