Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^2: What means: exit_value , signal_num and dumped_core

by Yaerox (Scribe)
on Apr 11, 2014 at 12:44 UTC ( #1081956=note: print w/replies, xml ) Need Help??

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 }

Replies are listed 'Best First'.
Re^3: What means: exit_value , signal_num and dumped_core
by Bloodnok (Vicar) on Apr 11, 2014 at 13:02 UTC
    It's because the exit code, signal number and core dump flag are all rolled up into a word i.e. a single 16 bit, value - the bitwise operators are used to extract the various bits of the word.

    Note, also, that just because a process exits with a non-zero signal, it doesn't necessarily mean that a core dump will have been generated as the process exited.

    A user level that continues to overstate my experience :-))

      Ahh, okay, now I got it ^^

      Thank you very much Sir.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1081956]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (1)
As of 2022-07-06 03:50 GMT
Find Nodes?
    Voting Booth?

    No recent polls found