in reply to Re: Protection from zombies
in thread Protection from zombies
#!/usr/bin/perl use warnings; use strict; my $pid = open(F,"-|"); if (!defined($pid)) { die "fork error: $!\n"; } if ($pid) { # Parent print "PARENT: PID is $$\n"; sleep(1000); print <F>; close(F); } else { # Child exec("/bin/bash","-c", 'echo CHILD: PID is $$, PPID is $PPID >&2'); }
Below, notice that 20474 is the parent process, and its child 20476 is a zombie.
freenet{swgsh}~ $ perl tmp/t3 & [2] 20474 freenet{swgsh}~ $ PARENT: PID is 20474 CHILD: PID is 20476, PPID is 20474 freenet{swgsh}~ $ ps PID TTY TIME CMD 12912 pts/0 00:00:00 bash 13286 pts/0 00:00:39 emacs 20474 pts/0 00:00:00 perl 20476 pts/0 00:00:00 bash <defunct> 20487 pts/0 00:00:00 ps
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Protection from zombies
by mda2 (Hermit) on May 16, 2005 at 22:58 UTC | |
by sgifford (Prior) on May 17, 2005 at 04:05 UTC | |
by nomis80 (Sexton) on May 17, 2005 at 12:40 UTC | |
by nomis80 (Sexton) on May 17, 2005 at 12:50 UTC | |
by kscaldef (Pilgrim) on May 17, 2005 at 17:51 UTC |