You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a bug report for perl from [email protected],
generated with the help of perlbug 1.41 running under perl 5.30.1.
For some reason END blocks are not executed if
the program is blocked in a flush() call because a pipe buffer is
full
the block is interrupted by a SIGINT (possibly other signals; I haven't
tested)
the SIGINT is caught with a $SIG{INT} handler which calls exit()
If the program is blocked in any other way the END block is run as expected.
Minimal(-ish) demonstration:
#!/usr/bin/env perl
use strict;
use warnings;
$SIG{INT} = sub {
print "\nSIGINT received\n";
exit 2;
};
END {
print "END BLOCK\n";
}
my $child_pid = open my $child_handle, '|-', "sleep 9999"
or die "fork failed: $!\n";
# As soon as this overflows the 16-bit mark, and hence our writes start
# blocking on the pipe buffer, perl no longer seems to run END blocks on
# SIGINT?
my $count = 65537;
for (1..$count) {
print{$child_handle} "\n" or die "print failed: $!\n";
# SIGINT while this is blocked (because the pipe buffer is full) triggers
# the $SIG{INT} trap and exits the program, but does not execute the
# END block.
$child_handle->flush or die "flush failed: $!\n";
}
print "printing done\n";
# SIGINT while *this* is blocked (if we didn't fill the pipe buffer) triggers
# the SIGINT handler but also runs the END block.
waitpid $child_pid, 0;
To: [email protected]
Subject: END blocks not executed sometimes on SIGINT.
From: [email protected]
Message-Id: [email protected]
Reply-To: [email protected]
This is a bug report for perl from [email protected],
generated with the help of perlbug 1.41 running under perl 5.30.1.
For some reason END blocks are not executed if
flush()
call because a pipe buffer isfull
tested)
$SIG{INT}
handler which callsexit()
If the program is blocked in any other way the END block is run as expected.
Minimal(-ish) demonstration:
Perl Info
The text was updated successfully, but these errors were encountered: