Jonathan has asked for the wisdom of the Perl Monks concerning the following question:
I have a process that runs as a daemon forking off child processes when requests come in. To control zombies I have the standard
What is the best way to get at the exit code?
However, the child processes then have to make a system call and I need to trap the exit code eg..# Install signal handler for child processes $SIG{'CHLD'} = sub { while (waitpid(-1,WNOHANG) > 0) {} };
$? now contains -1 and $! 'No child processes', I understand that this is because of my $SIG{'CHLD'} handler. But how can I get the true exit code and message? I've tried 'local $SIG{'CHLD'} = '' prior to the sys call and that seems to work but looks very clumsy.my $res = system $cmd, $arg; unless ($res == 0) { ... }
What is the best way to get at the exit code?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: No child processes
by RMGir (Prior) on Sep 13, 2002 at 11:29 UTC | |
Re: No child processes
by slife (Scribe) on Sep 13, 2002 at 13:22 UTC | |
Re: No child processes
by PodMaster (Abbot) on Sep 13, 2002 at 11:14 UTC | |
Re: No child processes
by Jonathan (Curate) on Sep 13, 2002 at 13:36 UTC | |
Re: No child processes
by Anonymous Monk on Jun 07, 2018 at 15:33 UTC |
Back to
Seekers of Perl Wisdom