develooper Front page | perl.perl5.porters | Postings from March 2003

SIGCHLD and zombies issue

Stas Bekman
March 8, 2003 05:25
SIGCHLD and zombies issue
Message ID:
One of the readers of the mod_perl guide was trying to suggest why a 
localization of:


doesn't work. His suggestion of local() overriding the magic wasn't quite 
right, because it does work for other SIGnals. However things don't look quite 
right across quite a few perl versions, so it'd be nice to clear out this issue.

First of all, the following standalone script creates a zombie child process, 
contrary to what perlipc.pod says (tested with perl-5.005-03 .. perl-blead):


defined (my $kid = fork) or die "Cannot fork: $!\n";
if ($kid) {
     # no wait()/waitpid() on purpose!
     print "Parent has finished\n";
} else {
     # do something time-consuming

sleep 100; # zombie quits when sleep ends

$SIG{CHLD} = 'IGNORE'; doesn't take any effect. If you look in another 
console, on the list of processes you will see a <defunc> child process. This 
is at least how it looks on my machine (linux/2.4.19).

However the same script running under mod_perl does work. Meaning that 
whatever C layer should be affected by setting $SIG{CHLD} is not affected by 
Perl, while does affected by Apache C guts.

Now if you try to localize the setting under mod_perl, it breaks as well (we 
get a zombie)

Now I'm looking for input on different other ways to avoid zombies, this is 
covered in details here:

What I want to solve is:

1) why $SIG{CHLD} = 'IGNORE'; takes no effect in the plain perl script
2) why local $SIG{CHLD} = 'IGNORE'; doesn't behave quite the same as 
non-localized version

Also I doubt that this has anything to do with 5.8.0's deferred signals, since 
the problem is not different in earlier perls.

Thank you.

Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker     mod_perl Guide ---> Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About