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

Re: [perl #22339] IO::Handle::setvbuf not defined properly

From:
Mark Jason Dominus
Date:
May 28, 2003 09:27
Subject:
Re: [perl #22339] IO::Handle::setvbuf not defined properly
Message ID:
20030528162724.10403.qmail@plover.com

Nicholas Clark <nick@ccl4.org>:
> > a) use setvbuf() to discard the buffer, perhaps temporarily, or
> 
> My understanding is that one never was allowed to call setvbuf() midway on a
> stream:

Right, thanks.  Please forget about the 'perhaps temporarily' part.  I
added this as an afterthought in my message anyway.  The essential
problem is that I would like to do

        $rec = <FH>;

but that implies some sort of buffering, and the buffering confounds
concurrent access.  So I planned to use setvbuf to disabled the
buffering while stil permitting use of <FH>.


Kurt Starsinic <kstar@cpan.org>:
>    How about mmap(), 

I need features that are provided by standard perl, preferably back to
5.005.  As far as I know there's no entry to mmap except through
nonstandard CPAN modules.  PerlIO uses it internally, if it's
available, but doesn't make it available to me.

Kurt Starsinic <kstar@cpan.org>:
> or closing and re-opening the read() filehandle?

Not an option, I'm afraid.  It may not be re-openable.  

Using

        open $newfh, "<&=".fileno($oldfh) 

seems not to work for some reason that I haven't investigated yet.

Graham Barr <gbarr@pobox.com>:
> You could try using seek.

That works on my platform, but I worry that it's not portable.  I
can't think of any reason why 'seek' should necessarily discard the
buffered data.  Perhaps I'm overlooking something?






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