develooper Front page | perl.perl5.porters | Postings from September 2013

Re: [perl #7586] STDOUT is not flushed before exec().

Thread Previous | Thread Next
Nicholas Clark
September 16, 2013 09:09
Re: [perl #7586] STDOUT is not flushed before exec().
Message ID:
On Thu, Sep 12, 2013 at 05:42:39PM -0700, James E Keenan via RT wrote:
> On Sat May 26 16:19:46 2012, Hugmeir wrote:

> > I couldn't get the code to run either, but this sounds like several
> > other exec-not-flushing-STDOUT bugs that were fixed a while ago but only
> > closed recently. OP, if you are still around, are you still seeing this
> > issue with newer versions of Perl?
> > 
> > Since this ticket has been silent for over a decade, I recommend leaving
> > it open for thirty more days, then closing it unless we get new
> > information or other complains.
> > 
> > --hugmeir
> No response in 15 months.  Closing ticket.

The reported bug was fixed by this commit:

commit 76549fefd07754d43beb1146d96596a36d02db09
Author: Jarkko Hietaniemi <>
Date:   Sat Apr 28 14:26:13 2001 +0000

    For PerlIO flush the children's file handles (on fork/exec/system).
    p4raw-id: //depot/perl@9894

diff --git a/perl.h b/perl.h
index 01a6d3f..57afb3e 100644
--- a/perl.h
+++ b/perl.h
@@ -1842,10 +1842,12 @@ typedef pthread_key_t   perl_key;
 /* This defines a way to flush all output buffers.  This may be a
- * performance issue, so we allow people to disable it.
+ * performance issue, so we allow people to disable it.  Also, if
+ * we are using stdio, there are broken implementations of fflush(NULL)
+ * out there, Solaris being the most prominent.
-# if defined(FFLUSH_NULL) || defined(USE_SFIO)
+# if defined(USE_PERLIO) || defined(FFLUSH_NULL) || defined(USE_SFIO)
 #  define PERL_FLUSHALL_FOR_CHILD      PerlIO_flush((PerlIO*)NULL)
 # else
 #  ifdef FFLUSH_ALL

It turns out* that $Config{fflushNULL} on HP-UX is *STILL* undef, because
fflush(NULL) wrongly closes STDIN if STDIN is a pipe (which is what the
Configure test probes for).

I wonder if HP are even aware that their platform is still not quite 100%
C89 conformant? Of if they'll fix it in time for the 25th anniversary of
the first ANSI C standard?

(Also, given that that this bug had been present on Solaris, and on early
FreeBSDs, I wonder if it's a bug in common code they inherit from, or just
convergent mistake making)

Nicholas Clark

* At least on the system Merijn provides for us.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About