Re: unkillable process ?
Re: unkillable process ?
- Subject: Re: unkillable process ?
- From: Paul Ripke <email@hidden>
- Date: Tue, 8 Apr 2003 00:38:53 +1000
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.
OK, testing, looks like the process struct gets nulled (from a ps point
of view) when the process gets zombie status:
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
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...
Cheers,
--
Paul Ripke
Unix/OpenVMS/TSM/DBA
101 reasons why you can't find your Sysadmin:
68: It's 9AM. He/She is not working that late.
-- Koos van den Hout
_______________________________________________
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.