I do get
Wed Feb 11 20:52:08 CET 2009 _lostChild args: $VAR1 = [ -1 ]; rc=0
Probably a matter of who calls wait() first... (i.e. system() or you in your signal handler). Remember that signals are delivered asynchronously.
Update: an strace in my case shows:
... wait4(28813, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 28813 --- SIGCHLD (Child exited) @ 0 (0) --- rt_sigreturn(0) = 28813 rt_sigaction(SIGINT, {SIG_DFL}, NULL, 8) = 0 rt_sigaction(SIGQUIT, {SIG_DFL}, NULL, 8) = 0 read(6, "", 4) = 0 close(6) = 0 rt_sigprocmask(SIG_BLOCK, [CHLD], NULL, 8) = 0 wait4(-1, 0x7fff3bda0c04, 0, NULL) = -1 ECHILD (No child processe +s) write(1, "_lostChild args:\n", 17) = 17 write(1, "$VAR1 = [\n -1\n ]"..., 34) = 34 write(1, "\n", 1) = 1 rt_sigprocmask(SIG_UNBLOCK, [CHLD], NULL, 8) = 0 write(2, "rc=0\n", 5) = 5 close(4) = 0 exit_group(0) = ?
The first wait is from Perl's system(). Then the SIGCHLD is received, which leads to the next wait call from within the signal handler, which gets ECHILD, as the process has already been reaped by the previous system()'s wait...
In your case, the SIGCHLD presumably arrives a tad earlier (before the first wait).
In reply to Re: system() returns -1 with $SIG{CHLD}?
by almut
in thread system() returns -1 with $SIG{CHLD}?
by cmv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |