This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
util.c:my_pclose: Use NULL in PL_fdpid
authorFather Chrysostomos <sprout@cpan.org>
Thu, 5 Sep 2013 08:11:59 +0000 (01:11 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 5 Sep 2013 12:59:11 +0000 (05:59 -0700)
PL_fdpid is an AV, and as of ce0d59f AVs use NULL for nonexist-
ent elements.

Without using NULL for deleted elements of PL_fdpid, we end up with
pipes appearing to be open after they have actually been closed.

I don’t know how to write a test for this, but it makes
Proc::ParallelLoop pass its tests.

util.c

diff --git a/util.c b/util.c
index a2c2513..d2380b2 100644 (file)
--- a/util.c
+++ b/util.c
@@ -2755,7 +2755,7 @@ Perl_my_pclose(pTHX_ PerlIO *ptr)
     svp = av_fetch(PL_fdpid,fd,TRUE);
     pid = (SvTYPE(*svp) == SVt_IV) ? SvIVX(*svp) : -1;
     SvREFCNT_dec(*svp);
-    *svp = &PL_sv_undef;
+    *svp = NULL;
 #ifdef OS2
     if (pid == -1) {                   /* Opened by popen. */
        return my_syspclose(ptr);