develooper Front page | perl.perl5.porters | Postings from May 2004

Re: [perl #29883] Closing file seems to cause a seek operation

Alan Burlison
May 28, 2004 15:25
Re: [perl #29883] Closing file seems to cause a seek operation
Message ID:
Nicholas Clark wrote:

 > I had this hunch that it's because you're using exit() (rather than 
 > and I'd guess that exit is calling fflush(), and that you're hitting the
 > bug in Solaris that fflush() clobbers input streams.

That particular bug was fixed in Solaris 8, AFAIK, this is something 

 > (ie something non-conformant with C89. Yes. C EIGHTY nine. Not C99.
 > Everyone expecting universal C99 conformance any time soon will be
 > disappointed)

The behaviour exhibited is required by SVID.  It's doing what it is 
supposed to

 > IIRC this is fixed now, but I can still reproduce your loop on a 
Solaris 10
 > machine. However, if I change exit() to POSIX::_exit() the problem 
goes away.

As the fork() manpage says:

      An application should call _exit() rather than exit(3C)  if
      it  cannot execve(), since exit() will flush and close stan-
      dard I/O channels and thereby corrupt the  parent  process's
      standard I/O data structures.

Big rule:  Don't use exit() after fork(), use _exit().

Alan Burlison
-- Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About