Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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.

Andrew.

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


Comment on Re: Untitled question

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://21170]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2014-07-30 13:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (234 votes), past polls