develooper Front page | perl.perl5.porters | Postings from July 2006

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

Thread Previous
From:
Steve Peters via RT
Date:
July 5, 2006 07:26
Subject:
[perl #29883] Closing file seems to cause a seek operation
Message ID:
rt-3.6.HEAD-19067-1152108311-800.29883-15-0@perl.org
On Fri May 28 16:12:08 2004, alanbur wrote:
> Nicholas Clark wrote:
> 
> >>>I had this hunch that it's because you're using exit() (rather than
> >>
> >>_exit()),
> >>
> >>>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
> >>different.
> 
> Actually, it appears it wasn't fixed until Solaris 9.
> 
> > As this behaviour is replicatable in Solaris 10, it has to be
> something
> > different.
> 
> It is, it exactly your hunch - you shouldn't use exit() in a child
> process that doesn't exec, you should use _exit.
> 
> >>>(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
> >>do.
> >
> > I was meaning the fflush(NULL) behaviour, which seems not to be the
> cause
> > here, w.r.t. the C89 comment.
> >
> > And I wasn't clear - it wasn't a dig at Solaris in particular. It's
> more
> > a general frustration that the world sucks, and takes
> {sometime,maybe,never}
> > to achieve conformance with standards.
> 
> This area of behaviour is very poorly defined, and even appears to
> conflict in the various standards - there was an immense amount of
> legwork expended on trying to decide which behaviour was correct, and
> what happens now doesn't conflict with any of the relevant standards.
> 


So, instead of calling exit() from the child process, the following is
preferable.

{
    use POSIX ();
    POSIX::_exit(0);
}

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About