04bfb0
From fb5e77103dd443cc2112ba14dc665aa5ec072ce6 Mon Sep 17 00:00:00 2001
04bfb0
From: Tony Cook <tony@develop-help.com>
04bfb0
Date: Wed, 30 May 2018 14:03:04 +1000
04bfb0
Subject: [PATCH] (perl #122112) test for signal handler death in pclose
04bfb0
MIME-Version: 1.0
04bfb0
Content-Type: text/plain; charset=UTF-8
04bfb0
Content-Transfer-Encoding: 8bit
04bfb0
04bfb0
Signed-off-by: Petr Písař <ppisar@redhat.com>
04bfb0
---
04bfb0
 t/io/pipe.t | 23 ++++++++++++++++++++++-
04bfb0
 1 file changed, 22 insertions(+), 1 deletion(-)
04bfb0
04bfb0
diff --git a/t/io/pipe.t b/t/io/pipe.t
04bfb0
index f9ee65afe8..1d01db6af6 100644
04bfb0
--- a/t/io/pipe.t
04bfb0
+++ b/t/io/pipe.t
04bfb0
@@ -10,7 +10,7 @@ if (!$Config{'d_fork'}) {
04bfb0
     skip_all("fork required to pipe");
04bfb0
 }
04bfb0
 else {
04bfb0
-    plan(tests => 25);
04bfb0
+    plan(tests => 27);
04bfb0
 }
04bfb0
 
04bfb0
 my $Perl = which_perl();
04bfb0
@@ -241,3 +241,24 @@ SKIP: {
04bfb0
 
04bfb0
   is($child, -1, 'child reaped if piped program cannot be executed');
04bfb0
 }
04bfb0
+
04bfb0
+{
04bfb0
+    # [perl #122112] refcnt: fd -1 < 0 when a signal handler dies
04bfb0
+    # while a pipe close is waiting on a child process
04bfb0
+    my $prog = <
04bfb0
+\$SIG{ALRM}=sub{die};
04bfb0
+alarm 1;
04bfb0
+\$Perl = "$Perl";
04bfb0
+my \$cmd = qq(\$Perl -e "sleep 3");
04bfb0
+my \$pid = open my \$fh, "|\$cmd" or die "\$!\n";
04bfb0
+close \$fh;
04bfb0
+PROG
04bfb0
+    print $prog;
04bfb0
+    my $out = fresh_perl($prog, {});
04bfb0
+    $::TODO = "not fixed yet";
04bfb0
+    cmp_ok($out, '!~', qr/refcnt/, "no exception from PerlIO");
04bfb0
+    undef $::TODO;
04bfb0
+    # checks that that program did something rather than failing to
04bfb0
+    # compile
04bfb0
+    cmp_ok($out, '=~', qr/Died at/, "but we did get the exception from die");
04bfb0
+}
04bfb0
-- 
04bfb0
2.20.1
04bfb0