Commit 2ef157af authored by Richard Levitte's avatar Richard Levitte
Browse files

Make OpenSSL::Test::run() sensitive to signals



$? in perl gets the status value from wait(2), which is a word with
the exit code in the upper half and the number of a raised signal in
the lower half.  OpenSSL::Test::run() ignored the signal half up until
now.

With this change, we recalculate an exit code the same way the Unix
shells do, using this formula:

    ($? & 0x7f) ? ($? & 0x7f)|0x80 : ($? >> 8);

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
Reviewed-by: default avatarEmilia Käsper <emilia@openssl.org>
parent 71cdcfc6
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -324,12 +324,17 @@ sub run {
    my @r = ();
    my $r = 0;
    my $e = 0;

    # The dance we do with $? is the same dance the Unix shells appear to
    # do.  For example, a program that gets aborted (and therefore signals
    # SIGABRT = 6) will appear to exit with the code 134.  We mimic this
    # to make it easier to compare with a manual run of the command.
    if ($opts{capture}) {
	@r = `$prefix$cmd`;
	$e = $? >> 8;
	$e = ($? & 0x7f) ? ($? & 0x7f)|0x80 : ($? >> 8);
    } else {
	system("$prefix$cmd");
	$e = $? >> 8;
	$e = ($? & 0x7f) ? ($? & 0x7f)|0x80 : ($? >> 8);
	$r = $hooks{exit_checker}->($e);
    }