Skip to content

Commit 9f0c17a

Browse files
committed
Add exit code test (GH #19020):
This tests that when we kill a process through a shell, we get the correct exit code and signal. Unfortunately, this fails on some versions of Ubuntu and dash, which I believe shows a bug somewhere. There's a sleep() included because some systems might delay the signal until the -e'' execution would already finish.
1 parent 2c205b5 commit 9f0c17a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5916,6 +5916,7 @@ t/op/isa.t See if isa works
59165916
t/op/join.t See if join works
59175917
t/op/kill0.t See if kill works
59185918
t/op/kill0_child Process tree script that is kill()ed
5919+
t/op/kill9_shell_exit.t Check that we get the right exit code on shell execution kill signal
59195920
t/op/kvaslice.t See if index/value array slices work
59205921
t/op/kvhslice.t See if key/value hash slices work
59215922
t/op/lc.t See if lc, uc, lcfirst, ucfirst, quotemeta work

t/op/kill9_shell_exit.t

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!./perl -w
2+
3+
BEGIN {
4+
chdir 't' if -d 't';
5+
require './test.pl';
6+
set_up_inc('../lib');
7+
}
8+
9+
use strict;
10+
use warnings;
11+
12+
plan( 'tests' => 4 );
13+
14+
my $res = system qq($^X -e'\''kill "KILL", \$\$; sleep 100'\'');
15+
my $exit = $?;
16+
17+
is( $res, $exit, "system() result ($res) and \$? ($exit) are the same" );
18+
is( $exit, 9, "\$? ($exit) from a KILL signal is 9" );
19+
is( $exit >> 8, 0, 'OS exit code (shifted) is 0' );
20+
is( $exit & 127, 9, 'KILL signal (bitwise ANDed exit) is 9' );

0 commit comments

Comments
 (0)