From 5f1adadce1a7199507b6cb717e2e30261b0d02f5 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Sun, 22 Mar 2020 04:15:14 +0100 Subject: [PATCH] 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) --- util/wrap.pl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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); -- 2.25.1