http://qs321.pair.com?node_id=1081956


in reply to Re: What means: exit_value , signal_num and dumped_core
in thread What means: exit_value , signal_num and dumped_core

Firstly, thanks for the reply. So did I understood this right, that in case that the signal_num isn't equal to 0 coredump is having a value too and the child died unexpected?

But I'm still asking myself, why I have to check this on the bitwise-operand way with if ($? & 127)?

Here some sample code:

my $pid = fork( ); if ( defined $pid && $pid == 0 ) { # child system( $_[0]->arg ); if ($? == -1) { return "failed to execute: $!\n"; } elsif ($? & 127) { return "child died with signal %d, %s coredump\n", ($? + & 127), ($? & 128) ? 'with' : 'without'; } else { return "child exited with value " . $? >> 8; } } else { # parent }