diff options
author | Richard Levitte <levitte@openssl.org> | 2020-03-22 04:15:14 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-03-25 10:51:21 +0100 |
commit | 5f1adadce1a7199507b6cb717e2e30261b0d02f5 (patch) | |
tree | b7d629f60884d5a4d4d20055aaf3dc51434b2692 | |
parent | 402b00d57921a0c8cd641b190d36bf39ea5fb592 (diff) |
util/wrap.pl: Correct exit code when signalled
On Unix, a caught signal that exits the process does so with an exit
code that is 'signal | 128'. This modifies util/wrap.pl to mimic
that.
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/11379)
-rwxr-xr-x | util/wrap.pl | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/util/wrap.pl b/util/wrap.pl index 4c3d4713f1..fd24c42c8b 100755 --- a/util/wrap.pl +++ b/util/wrap.pl @@ -35,5 +35,12 @@ my $waitcode = system @cmd; # (exitcode << 8 | signalcode) die "wrap.pl: Failed to execute '", join(' ', @cmd), "': $!\n" if $waitcode == -1; -exit($? & 255) if ($? & 255) != 0; + +# When the subprocess aborted on a signal, mimic what Unix shells do, by +# converting the signal code to an exit code by setting the high bit. +# This only happens on Unix flavored operating systems, the others don't +# have this sort of signaling to date, and simply leave the low byte zero. +exit(($? & 255) | 128) if ($? & 255) != 0; + +# When not a signal, just shift down the subprocess exit code and use that. exit($? >> 8); |