develooper Front page | perl.perl5.porters | Postings from January 2011

[perl #82802] [PATCH] fileno should return undef when PerlIO returns -1

Thread Next
Father Chrysostomos via RT
January 30, 2011 16:39
[perl #82802] [PATCH] fileno should return undef when PerlIO returns -1
Message ID:
On Wed Jan 26 06:23:43 2011, LeonT wrote:
> On Wed, Jan 26, 2011 at 11:21 AM, Bo Lindbergh <>
> > s/fixes/breaks/;
> >
> > A return value of -1 from a fileno method is not an error indicator;
> > it means that there's no operating system file descriptor
> > at the bottom of the layer stack (e.g. PerlIO::Scalar).
> >
> > The current behaviour of pp_fileno is correct since defined(fileno(FOO))
> > is the canonical way of testing whether a filehandle is open.
> The documentation of fileno explicitly disagrees: «Filehandles
> connected to memory objects via new features of "open" may return
> undefined even though they are open.» It has been in there for 10
> years (b76cc8ba).

But is it the documentation or the implementation that is wrong? What
does Jesse think?

> There is a way to check if a filehandle is open, it just hasn't ever
> been documented and it is rather obscure (welcome to PerlIO): that's a
> good reason to abstract it in openhandle. Overloading fileno with this
> never was a good idea IMO.
> Leon

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