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
You've missed this note in the PHP manual for stream_select():
When stream_select() returns, the arrays read, write and except are modified to indicate which stream resource(s) actually changed status.
You need to re-create the arrays before calling stream_select() each time.
Depending on the process you're opening, this may be why your example still blocks.