Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the IPC-System-Simple CPAN distribution.

Report information
The Basics
Id: 46684
Status: rejected
Priority: 0/
Queue: IPC-System-Simple

People
Owner: PJF [...] cpan.org
Requestors: PJF [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: IPC::System::Simple can return "No child processes" (ECHILD) when $SIG{CHLD} is set.
Due to the way in which Perl internally handles the reaping of child processes, the presence of a $SIG{CHLD} can prevent IPC::System::Simple from gaining access to return information, which then causes it to throw an exception claiming that it can't start the program, with "No child processes" as the reason why. Eg: #!/usr/bin/perl -w use strict; use IPC::System::Simple qw(run); use POSIX; $SIG{CHLD} = sub { while (waitpid(-1,WNOHANG) > 0) { } }; run("echo hello world"); This looks like it may be hard to fix, but can be worked around by temporarily unsetting the signal handler: #!/usr/bin/perl -w use strict; use IPC::System::Simple qw(run); use POSIX; $SIG{CHLD} = sub { while (waitpid(-1,WNOHANG) > 0) { } }; { local $SIG{CHLD} = 'DEFAULT'; run("echo hello world"); } The only gotcha here is that if your existing signal handler actually did something important, then we're breaking it for the duration of our local block. If the existing signal handler was merely making sure child processes get reaped (which is usually the case), then the code above is harmless.
On Fri Jun 05 03:51:48 2009, PJF wrote: Show quoted text
> Due to the way in which Perl internally handles the reaping of child > processes, the presence of a $SIG{CHLD} can prevent IPC::System::Simple > from gaining access to return information, which then causes it to throw > an exception claiming that it can't start the program, with "No child > processes" as the reason why. Eg: > > #!/usr/bin/perl -w > use strict; > use IPC::System::Simple qw(run); > use POSIX; > > $SIG{CHLD} = sub { while (waitpid(-1,WNOHANG) > 0) { } }; > > run("echo hello world"); > > This looks like it may be hard to fix, but can be worked around by > temporarily unsetting the signal handler: > > #!/usr/bin/perl -w > use strict; > use IPC::System::Simple qw(run); > use POSIX; > > $SIG{CHLD} = sub { while (waitpid(-1,WNOHANG) > 0) { } }; > > { > local $SIG{CHLD} = 'DEFAULT'; > run("echo hello world"); > } > > The only gotcha here is that if your existing signal handler actually > did something important, then we're breaking it for the duration of our > local block. If the existing signal handler was merely making sure > child processes get reaped (which is usually the case), then the code > above is harmless.
This ticket has been moved to the github issues queue for this distribution: https://github.com/pjf/ipc-system-simple/issues/36 Thank you very much. Jim Keenan