This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(perl #122112) make sure SIGPIPE is delivered if we test it
authorTony Cook <tony@develop-help.com>
Tue, 25 Jun 2019 05:47:57 +0000 (15:47 +1000)
committerTony Cook <tony@develop-help.com>
Wed, 26 Jun 2019 01:19:51 +0000 (11:19 +1000)
t/io/pipe.t

index 9f5bb3b..bdf743c 100644 (file)
@@ -125,6 +125,18 @@ wait;                              # Collect from $pid
 pipe(READER,WRITER) || die "Can't open pipe";
 close READER;
 
+eval {
+    # one platform at least appears to block SIGPIPE by default (see #122112)
+    # so make sure it's unblocked.
+    # The eval wrapper should ensure this does nothing if these aren't
+    # implemented.
+    require POSIX;
+    my $mask = POSIX::SigSet->new(POSIX::SIGPIPE());
+    my $old = POSIX::SigSet->new();
+    POSIX::sigprocmask(POSIX::SIG_UNBLOCK(), $mask, $old);
+    note "Yes, SIGPIPE was blocked" if $old->ismember(POSIX::SIGPIPE());
+};
+
 $SIG{'PIPE'} = 'broken_pipe';
 
 sub broken_pipe {