in reply to Re^3: How to share streams between processes
in thread How to share streams between processes

Thanks for that reply. I needed to keep them separate but managed in the end to find both a solution and the reason for me to have the trouble in the first place. Seems like I forgot to flush the stream which made it seem the processes did not work in parallel;

<P> select((select(STDOUT), $|=1)[0]); <P> And the whole script that made it all work: <br> <br>$pid = open3(*CMD_IN, *CMD_OUT, *CMD_ERR, $path, @arguments); <br> close(CMD_IN); <br> <br> $selector = IO::Select->new(); <br> $selector->add(*CMD_ERR, *CMD_OUT); <br> <br> while(@ready = $selector->can_read) { <br> foreach my $fh (@ready) { <br> if(fileno($fh) == fileno(CMD_ERR)) { <br> my $line = scalar <CMD_ERR>; <br> if(defined $line) { <br> parseErrorStream($line); <br> } <br> } <br> else { <br> my $line2 = scalar <CMD_OUT>; <br> if(defined $line2 and $print eq 1) { <br> parseStandardStream($line2); <br> } <br> } <br> $selector->remove($fh) if eof($fh); <br> } <br> } <br> close(CMD_OUT); <br> close(CMD_ERR);