in reply to ipc::open3 start process
I think you are reading too soon from your child process and the socket isn't readable resp. doesn't have output on it yet:
while ( my @ready = $select->can_read()) { ... };
A quick fix could be to sleep some time before first trying to read output of the child:
sleep 2; # give time to child process while ( my @ready = $select->can_read()) { ... };
A better fix would most likely be to split up output reading and child checking into two parts, but checking if a child is still running/alive is hard to do unless you know on what OS you will be running:
my @children = get_child_pids(); # fake while (@children) { while ( my @ready = $select->can_read()) { ... }; @children = get_child_pids(); # fake sleep 5; # let's see if the remaining children will produce output };
I'm punting on the check for alive children. The easiest way to check for alive children would be if you're under Linux to check for -d /proc/$child_pid, and maybe there is some way in Perl to get at the list of PIDs associated with your current PID, but I don't know it at the moment. Somebody else will chime in with that, I hope. CPAN might know too.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: ipc::open3 start process
by edan (Curate) on Dec 14, 2004 at 12:03 UTC |