From: Richard Levitte Date: Sun, 22 Mar 2020 03:15:14 +0000 (+0100) Subject: util/wrap.pl: Correct exit code when signalled X-Git-Tag: openssl-3.0.0-alpha1~219 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5f1adadce1a7199507b6cb717e2e30261b0d02f5;p=oweals%2Fopenssl.git 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 (Merged from https://github.com/openssl/openssl/pull/11379) --- 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);