Skip to content
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
2 changes: 0 additions & 2 deletions t/io/closepid.t
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,3 @@ SKIP:
kill $killsig, $pid;
open STDIN, "<&", $savein;
}

watchdog(0);
2 changes: 0 additions & 2 deletions t/io/openpid.t
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,3 @@ next_test();
print "# waiting for process $pid4 to exit\n";
$reap_pid = waitpid $pid4, 0;
is( $reap_pid, $pid4, 'fourth process reaped' );

watchdog(0);
2 changes: 0 additions & 2 deletions t/op/sigdispatch.t
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,3 @@ like $@, qr/No such hook: __DIE__\\0whoops at/;
is($int_called, 1);
is($@, "died");
}

watchdog(0);
3 changes: 0 additions & 3 deletions t/op/signame_canonical.t
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,3 @@ foreach my $dupe (@duplicate_signals) {
is( $SIG{$dupe}, undef, "The signal $dupe is cleared after local goes out of scope." );
is( $SIG{$canonical_name}, undef, "The signal $canonical_name is cleared after local goes out of scope." );
}

watchdog(0);

2 changes: 0 additions & 2 deletions t/op/study.t
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,3 @@ TODO: {
push @got, $_ foreach $a =~ /[^x]d(?{$a .= ''})[^x]d/g;
is("@got", 'ydyd ydyd', '#92696 $a .= \'\' inside (?{}), $a studied');
}

watchdog(0);
2 changes: 0 additions & 2 deletions t/op/time.t
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,3 @@ SKIP: {
is scalar gmtime("NaN"), undef, '[perl #123495] gmtime(NaN)';
is scalar localtime("NaN"), undef, 'localtime(NaN)';
}

watchdog(0);
2 changes: 0 additions & 2 deletions t/op/time_loop.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ watchdog(2);
local $SIG{__WARN__} = sub {};
is gmtime(2**69), undef;
is localtime(2**69), undef;

watchdog(0);
1 change: 0 additions & 1 deletion t/op/waitpid.t
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@ watchdog(10);

pass("didn't block on waitpid(0, ...)");
}
watchdog(0);

done_testing();
2 changes: 0 additions & 2 deletions t/perf/speed.t
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@ SKIP: {
pass("COW 1Mb strings");
}

watchdog(0);

1;
2 changes: 0 additions & 2 deletions t/perf/taint.t
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,4 @@ my $taint = substr($ENV{PATH}, 0, 0); # and empty tainted string
pass("RT #130584 pos on tainted utf8 string");
}

watchdog(0);

1;
1 change: 0 additions & 1 deletion t/re/fold_grind.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,6 @@ (@)
}
}

watchdog(0);
plan($count);

1
51 changes: 22 additions & 29 deletions t/test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1829,8 +1829,7 @@ sub warning_like {
# NOTE: If the test file uses 'threads', then call the watchdog() function
# _AFTER_ the 'threads' module is loaded.
{ # Closure
my $watchdog;
my $watchdog_thread;
my $cancel_string;

sub watchdog ($;$)
{
Expand All @@ -1839,29 +1838,18 @@ ($;$)
# If cancelling, use the state variables to know which method was used to
# create the watchdog.
if ($timeout == 0) {
if ($watchdog_thread) {
$watchdog_thread->kill('KILL');
undef $watchdog_thread;
}
elsif ($watchdog) {
kill('KILL', $watchdog);
undef $watchdog;
}
else {
alarm(0);
}

eval $cancel_string if defined $cancel_string;
return;
}

# Make sure these aren't defined.
undef $watchdog;
undef $watchdog_thread;

my $method = shift || "";

my $timeout_msg = 'Test process timed out - terminating';

# Common to all cancellation types; HERE gets replaced by the individual
# code
$cancel_string = 'local $! = 0; local $? = 0; HERE; undef $cancel_string';

# Accept either spelling
my $timeout_factor = $ENV{PERL_TEST_TIME_OUT_FACTOR}
|| $ENV{PERL_TEST_TIMEOUT_FACTOR}
Expand All @@ -1886,6 +1874,7 @@ ($;$)
# Don't use a watchdog process if 'threads' is loaded -
# use a watchdog thread instead
if (!$threads_on || $method eq "process") {
my $watchdog;

# On Windows and VMS, try launching a watchdog process
# using system(1, ...) (see perlport.pod). system() returns
Expand All @@ -1904,7 +1893,6 @@ ($;$)
return if ($pid_to_kill <= 0);

# Launch watchdog process
undef $watchdog;
eval {
local $SIG{'__WARN__'} = sub {
_diag("Watchdog warning: $_[0]");
Expand Down Expand Up @@ -1945,22 +1933,21 @@ ($;$)
return;
}

# Add END block to parent to terminate and
# clean up watchdog process
eval("END { local \$! = 0; local \$? = 0;
wait() if kill('KILL', $watchdog); };");
# Add END block to parent to terminate and clean up watchdog
# process
$cancel_string =~ s/HERE/wait() if kill('KILL', $watchdog)/;
eval("END { $cancel_string };");
return;
}

# Try using fork() to generate a watchdog process
undef $watchdog;
eval { $watchdog = fork() };
if (defined($watchdog)) {
if ($watchdog) { # Parent process
# Add END block to parent to terminate and
# clean up watchdog process
eval "END { local \$! = 0; local \$? = 0;
wait() if kill('KILL', $watchdog); };";
# Add END block to parent to terminate and clean up watchdog
# process
$cancel_string =~ s/HERE/wait() if kill('KILL', $watchdog)/;
eval("END { $cancel_string };");
return;
}

Expand Down Expand Up @@ -1998,7 +1985,7 @@ ($;$)
# Use a watchdog thread because either 'threads' is loaded,
# or fork() failed
if (eval {require threads; 1}) {
$watchdog_thread = 'threads'->create(sub {
my $watchdog_thread = 'threads'->create(sub {
# Load POSIX if available
eval { require POSIX; };

Expand All @@ -2022,6 +2009,9 @@ ($;$)
kill($sig, $pid_to_kill);
});

$cancel_string =~ s/HERE/$watchdog_thread->kill('KILL')->detach()/;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$watchdog_thread would be replaced at this point, producing code like threads=SCALAR(0x55e3bd6a7ab0)->kill('KILL')->detach() which will just fail to compile.

eval "END { $cancel_string }";

# Don't proceed until the watchdog has set up its signal handler.
# (Otherwise there is a possibility that we will exit with threads
# running.) The watchdog tells us that the handler is set by
Expand Down Expand Up @@ -2049,6 +2039,9 @@ ($;$)
my $sig = $is_vms ? 'TERM' : 'KILL';
kill($sig, $pid_to_kill);
};

$cancel_string =~ s/HERE/alarm(0)/;
eval "END { $cancel_string }";
}
}
} # End closure
Expand Down
2 changes: 0 additions & 2 deletions t/win32/popen.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@ for(1..100) {
}
PERL

watchdog(0);

done_testing();
Loading