stevieb9 / ipc-shareable

Share Perl variables across processes and scripts
GNU General Public License v2.0
3 stars 2 forks source link

Setting $SIG{CHLD} = 'IGNORE' globally causes all subsequent calls to system() to fail. #15

Closed juddtaylor closed 2 years ago

juddtaylor commented 2 years ago

I just recently updated my systems from IPC::Shareable 0.61 to 1.06 during my transition to Rocky Linux 8, and now my code is failing on all external system() calls. The culprit is setting $SIG{CHLD} = 'IGNORE' globally at the top of Shareable.pm. Are you sure you shouldn't be doing that locally?

Using IPC::Shareable (used or not) result in all subsequent calls to system to return -1, and set $! to 'No child processes'.

The following code will cause this error:

!/usr/bin/perl

use strict;

use IPC::Shareable;

my @command = ( '/usr/bin/date', '--version' );

print "Running command: \'" . join(" ",@command) . "\'\n";

$SIG{CHLD} = 'IGNORE';

my $rc = system( @command ); if( $rc ) { my $exit = $? >> 8; my $sig = $? & 127; my $core = $? & 128; die "Command failed! (rc=$rc, exit=$exit, sig=$sig, core=$core, \$!=\'$!\')\n"; }

print "\n\nExit status: $rc ($!)\n";

exit(0);