Is there anyway to read from STDIN
with PHP that is non blocking:
I tried this:
stream_set_blocking(STDIN, false);
echo fread(STDIN, 1);
Petah, I can't help with the PHP side of this directly, but I can refer you to an article I ran across a while ago in which someone emulated transistors by testing within a shell script for the existence of pending data for a named pipe. It's a fascinating read, and takes shell scripting to a whole new level of geekiness. :-)
The article is here: http://www.linusakesson.net/programming/pipelogic/
So ... in answer to your "crude hacks" request, I suppose you could shunt your stdio through named pipes, then exec()
the tool whose source is included at the URL above to test whether anything is waiting to be sent through the pipe. You'd probably want to develop some wrapper functions to help with stuff.
I suspect the pipelogic solution is Linux-only, or at least would require a unix-like operating system. No idea how this could be accomplished on Windows.