Skip to content

Add exit code test (GH #19020): #19152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: blead
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -5916,6 +5916,7 @@ t/op/isa.t See if isa works
t/op/join.t See if join works
t/op/kill0.t See if kill works
t/op/kill0_child Process tree script that is kill()ed
t/op/kill9_shell_exit.t Check that we get the right exit code on shell execution kill signal
t/op/kvaslice.t See if index/value array slices work
t/op/kvhslice.t See if key/value hash slices work
t/op/lc.t See if lc, uc, lcfirst, ucfirst, quotemeta work
Expand Down
20 changes: 20 additions & 0 deletions t/op/kill9_shell_exit.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!./perl -w

BEGIN {
chdir 't' if -d 't';
require './test.pl';
set_up_inc('../lib');
}

use strict;
use warnings;

plan( 'tests' => 4 );

my $res = system qq($^X -e'\''kill "KILL", \$\$; sleep 100'\'');
my $exit = $?;

is( $res, $exit, "system() result ($res) and \$? ($exit) are the same" );
is( $exit, 9, "\$? ($exit) from a KILL signal is 9" );
is( $exit >> 8, 0, 'OS exit code (shifted) is 0' );
is( $exit & 127, 9, 'KILL signal (bitwise ANDed exit) is 9' );