I was using a function that made use of proc_open()
to invoke shell commands. It seems the way I was doing STDIO was wrong and sometimes cause
while($r = stream_select($read, $write, $except, null, $timeout)){
As far as I know this will set $r to the number of changed streams, which may be 0 and the loop would no longer continue. I would personally recode this as described in the PHP manual:
while(false !== ($r = stream_select($read, $write, $except, null, $timeout))){
As far as your STDIN is concerned if your process is not interactive then the STDIN may not be necessary. What is the process you are executing?