Phoenix.pm: SIG{CHLD} problems

Mike Cantrell mikec at autodispatch.com
Mon Jul 17 13:49:47 CDT 2000


I'm using fork() in a program for the first time and I'm having some problems.

Inside the child's code, I've got a glob() that keeps triggering the SIG{CHLD} subroutine. The interesting thing is that the error states that the glob dumped core but it didn't:

    glob failed (child exited with status -1, core dumped) at ./manager line 152, <_GEN_0> chunk 1.


I know that sysetm(), backticks, etc cause forks but they should be checking for their own children. Could it be possible that glob() forks but doesn't clean up after itself? Has anyone else had similar problems?


Here's the assigned routine to $SIG{CHLD}: (yep, straight outta the cookbook)

$SIG{CHLD} = \&REAPER;
sub REAPER {
    my $pid;

    $pid = waitpid(-1, &WNOHANG);

    if ($pid == -1) {
        # no child waiting.  Ignore it.
    } elsif (WIFEXITED($?)) {
        print "Process $pid exited.\n";
    } else {
        print "False alarm on $pid.\n";
    }
    $SIG{CHLD} = \&REAPER;          # in case of unreliable signals
}



Regards,
Mike Cantrell

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/phoenix-pm/attachments/20000717/a9bdf300/attachment.htm


More information about the Phoenix-pm mailing list