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