The close fails because of the wait done already ($! for the failure is "No child processes"). Calling wait doesn't close the pipe, however, so you can still read from it. Perl isn't maintaining the output of the program anywhere; that's the OS's job.
The OS does keep a buffer for the job's output between it and perl. If the child process fills that buffer before you read anything out of it, the child will stop (at the OS's request), and your wait loop will loop forever.
A better way to handle your pipes is with (four argument) select or IO::Select. Using select and IO::Select might be a good place to look. What you want to do is read from them when there's something to read, but don't get stuck waiting on them when there's nothing to read.
In reply to Re: wait versus close on a pipe
by kyle
in thread wait versus close on a pipe
by daven7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |