On Tue, Jan 20, 2004 at 05:27:22PM +0000 Nick Ing-Simmons wrote:

> Tassilo Parseval <[EMAIL PROTECTED]> writes:
> >
> >My concern was with PerIO_fdopen(). I didn't know whether perl would
> >reuse the fd (and simply sort of wrap it in a PerlIO) or duplicate it.
> 
> There is a pod which tells you.

I missed the entry on PerlIO_fdopen (it is bundled with PerlIO_open). I
should have used '/' in perldoc.

> >In case of duping, ignoring O_NONBLOCK would be bad.
> 
> AFAIK a dup()ed fd inherits the non-blocking-ness along with 
> all the other kernel level attributes like file position.

As I've read in the PODs now, PerlIO_fdopen() will not dup the handle
(since fdopen wont do it) and so I can't use it. perlapio.pod mentions
"dup" only once (in PerlIO_reopen) and that doesn't help:

   Perl prefers to "dup" the new low-level descriptor to the descrip-
   tor used by the existing PerlIO. This may become the behaviour of
   this function in the future.

I've come to the conclusion that I will use the "<&$fd" trick and use
do_openn() because thus I can pass 'Nullfp' as the PerlIO* argument.

> >The problem with fd-versus-FILE IO is eventually what bothers me. 
> 
> For Perl5.8+ you can avoid the buffering issues of that problem
> by just using :unix layer.

This is good to know. I haven't yet looked much into the layers stuff
though.

> >> >    #define sv_to_file(sv) (PerlIO_exportFILE(IoIFP(sv_2io(sv)), NULL))
> >> >
> >> That is "okay" anywhere with perl5.8+ - but please read the PODs.
> >> In perl5.8+ there isn't necessarily a FILE * in normal perl IO.
> >> So the above may have to 
> >> 
> >>     FILE *stdio = fdopen(PerlIO_fileno(pio),mode))
> >
> >Sigh, so not even my non-Win32 path is necessarily right.
> 
> Why do you need a FILE *?
> Won't a PerlIO * do? - you always have one of those.
> 
> IMHO you only need a FILE * for passing external C libraries
> that expect such a thing.

This was my situation. The library was able to deal with either a
filename or a FILE* handle. It was therefore natural to allow the same
thing from Perl.

> >Anyway, Nick, thanks for your patient attempts to explain this book
> >with 7^7 seals to me. I think I'm now able to find a way through this
> >muddle somehow.
> 
> I will try and remember to add the essence of these discussions 
> to the PODs.

That would be really nice. I simply cannot imagine that I am the only
one having such a hard time with perlio.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval

Reply via email to