Skip to content
Merged
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
14 changes: 10 additions & 4 deletions t/01_run.t
Original file line number Diff line number Diff line change
Expand Up @@ -613,17 +613,23 @@ subtest 'execute exeption handling' => sub {
};

subtest 'SIG_CHLD handler in spawned process' => sub {
my $simple_rwp = "$FindBin::Bin/data/simple_rwp.pl";
my $simple_rwp = "$FindBin::Bin/data/simple_rwp.pl";
my $sigchld_handler = "$FindBin::Bin/data/sigchld_handler.pl";

# use `perl <script>` here, as Github ci action place the used perl executable
# somewhere like /opt/hostedtoolcache/perl/<version>/<arch>/bin/perl so
# /usr/bin/perl wouldn't have all needed dependencies
is( process(execute => 'perl')->args([$simple_rwp])->start()->wait_stop()->exit_status(), 0, 'simple_rwp.pl exit with 0');
is(
process(execute => 'perl')->args([$simple_rwp])->start()->wait_stop()
->exit_status(),
0,
'simple_rwp.pl exit with 0'
);

my $p = process(execute => $sigchld_handler);
is( $p->start()->wait_stop()->exit_status(), 0, 'sigchld_handler.pl exit with 0');
like( $p->read_all_stdout, qr/SIG_CHLD/, "SIG_CHLD handler was executed");
is($p->start()->wait_stop()->exit_status(),
0, 'sigchld_handler.pl exit with 0');
like($p->read_all_stdout, qr/SIG_CHLD/, "SIG_CHLD handler was executed");
};

done_testing;
6 changes: 3 additions & 3 deletions t/data/sigchld_handler.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

my $collected_pid = -1;
$SIG{CHLD} = sub {
$collected_pid = waitpid(-1, 0);
print "SIG_CHLD $collected_pid exit:" . ( $?>>8) . "\n";
$collected_pid = waitpid(-1, 0);
print "SIG_CHLD $collected_pid exit:" . ($? >> 8) . "\n";
};

my $pid = fork();
Expand All @@ -15,6 +15,6 @@
exit 0;
}
print "Forked child is $pid\n";
sleep 0.1 while($collected_pid != $pid);
sleep 0.1 while ($collected_pid != $pid);
print "Exit graceful\n";
exit 0;