Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Untitled question

by ahunter (Monk)
on Jul 05, 2000 at 21:45 UTC ( #21170=note: print w/replies, xml ) Need Help??

in reply to More IPC::Open2 stuff

Hmm, the buffering problems outlined in my select tutorial (here) also apply to open2, and indeed any other type of file that can block. If you're reading from multiple files, you can use the Multiplex package presented there (and you can use it to implement timeouts, too). Use sysread and syswrite to write to the filehandles returned by open2 (if you're only reading from one filehandle, you don't really need the complexities of using select, and $SIG{ALRM} will let you interrupt something that's blocking)

Setting the filehandle to nonblocking is probably not the answer to this, but it may help with the buffering problem. If you do set the nonblocking flag, use select to avoid having to poll the filehandle.

Use sysread to read one byte at a time, or set the filehandle nonblocking and read (say) 256 at a time, but use select to wait for more to arrive.


(Hrm, I think untitled nodes should be given default names so we can click on them in newest nodes)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://21170]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2017-11-19 13:06 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (281 votes). Check out past polls.