Mailing List Archive

Failed mail (msg.af17854)
Your message could not be delivered to
'perlbug@perl.com (host: perl.com) (queue: smtpns)' for the following
reason: ' <perlbug@perl.com>... User unknown'


Your message follows:

Date: Mon, 4 Dec 1995 12:28:03 +0000
From: Tim Bunce <Tim.Bunce@ig.co.uk>
Message-Id: <9512041228.AA27277@toad.ig.co.uk>
To: teacher@aachen.eed.ericsson.se, kjahds@kjahds.com
Subject: Re: CGI::Carp 1.01 available for discussion
Cc: hedlund@best.com, tchrist@mox.perl.com, CGI-perl@webstorm.com,
perlbug@perl.com
X-Sun-Charset: US-ASCII
content-length: 1919


> From: Kenneth Albanowski <kjahds@kjahds.com>
>
> On Tue, 28 Nov 1995, Tom Christiansen wrote:
>
> > This is another part of the annoyance of filehandles being a rickety
> > construct in perl. If you get one that's a proper filehandle instead
> > of this oh-so-horrible strings, then you can't always do the right things
> > with them. In particular, >& redirection for dup's is broken. Here's
> > the work-around:
> >
> > $fd = fileno($fh); # should work for all of them
> > open(NEWFD, ">&$fd"); # dup()
> > open(NEWFD, ">&=$fd"); # fdopen()
>
> Given that this workaround exists, obviously any FileHandle module should
> provide some sort of simplified interface to this, either in a massivly
> overloaded open(), or in separate dup() and fdopen() methods.

I suspect that there _may_ be a problem if the filehandle is a socket since
the open (do_open() in doio.c) will not have access to the IoTYPE of the
original handle. Consider this (slightly simplified) code:

if (isDIGIT(*name))
fd = atoi(name);
else {
IO* thatio;
gv = gv_fetchpv(name,FALSE,SVt_PVIO);
thatio = GvIO(gv);
if (IoIFP(thatio)) {
fd = fileno(IoIFP(thatio));
if (IoTYPE(thatio) == 's')
IoTYPE(io) = 's';
}
else
fd = -1;
}

I believe that this may have been the cause of some strange problems I had
with CGI::MiniSvr in the early days. I never got to the bottom of it.
It worked when I changed to open(STDIN ,"<&CLIENT") and not use fileno().

FileHandle should have a dup method which we can work to improve.

Tim.

p.s. It's sort'a nice to be back. The perl5-porters have been having fun.
Only ~1000 more messages (3.6Mb) to read...


----- End Included Message -----