Skip to content

Commit 71e3636

Browse files
committed
Merge branch 'jk/t5562-racefix'
Test update. * jk/t5562-racefix: t5562: use alarm() to interrupt timed child-wait
2 parents 2a6d0b2 + e8f5556 commit 71e3636

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

t/t5562/invoke-with-content-length.pl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
defined read($body_fh, $body_data, $body_size) or die "Cannot read $body_filename: $!";
1414
close($body_fh);
1515

16-
my $exited = 0;
17-
$SIG{"CHLD"} = sub {
18-
$exited = 1;
19-
};
20-
2116
# write data
2217
my $pid = open(my $out, "|-", @command);
2318
{
@@ -29,8 +24,13 @@
2924
}
3025
print $out $body_data or die "Cannot write data: $!";
3126

32-
sleep 60; # is interrupted by SIGCHLD
33-
if (!$exited) {
34-
close($out);
27+
$SIG{ALRM} = sub {
28+
kill 'KILL', $pid;
3529
die "Command did not exit after reading whole body";
30+
};
31+
alarm 60;
32+
33+
my $ret = waitpid($pid, 0);
34+
if ($ret != $pid) {
35+
die "confusing return from waitpid: $ret";
3636
}

0 commit comments

Comments
 (0)