Don't ask to ask, just ask | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Just a guess... But I think that it is still blocking on the READ handle because the WRITE handle is still open.
Yup, just checked. That is what is happening...
Try that code with and without the close(WRITE) line commented out. If you comment it out it hangs. Here is some more trouble that you're going to run into. Because you need to close the WRITE handle before the <READ> will stop, you are going to run into a buffer limitation (actually this could happen anyway). On many systems a pipe buffer can only accept 4k to 8k before it blocks. It will block until somebody cleans it out by reading the READ end. This means if the output of your command is too big, just executing it will block as it tries to put all of it's info into the WRITE handle. The way to fix all of this is to pipe, fork, have the parent READ and the child WRITE. my @a=qw(random brilliant braindead); print $a[rand(@a)]; In reply to Re: Re: Re: capturing STDOUT
by Rhandom
|
|