I have a similar issue which is caused by the underlying socket timeout.
Eg. I create some streams
$streams = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
Then fork, and use a block such as the following
stream_set_blocking($pipes[1], 1); stream_set_blocking($pipes[2], 1); $pipesToRead = array($pipes[1], $pipes[2]); while (!feof($pipesToRead[0]) || !feof($pipesToRead[1])) { $reads = $pipesToRead; $writes = null; $excepts = $pipesToRead; $tSec = null; stream_select($reads, $writes, $excepts, $tSec); // while it's generating any kind of output, duplicate it wherever it // needs to go foreach ($reads as &$read) { $chunk = fread($read, 8192); foreach ($streams as &$stream) fwrite($stream, $chunk); } }
Glossing over what other things might be wrong there, my $tSec argument to stream_select is ignored, and the "stream" will timeout after 60 seconds of inactivity and produce an EOF.
If I add the following after creating the streams
stream_set_timeout($streams[0], 999); stream_set_timeout($streams[1], 999);
Then I get the result I desire, even if there's no activity on the underlying stream for longer than 60 seconds.
I feel that this might be a bug, because I don't want that EOF after 60 seconds of inactivity on the underlying stream, and I don't want to plug in some arbitrarily large value to avoid hitting the timeout if my processes are idle for some time.
In addition, even if the 60 second timeout remains, I think it should just timeout on my stream_select() call and my loop should be able to continue.