I have created a process using proc-open but under windows the stream-select does not work. What I am trying to achieve is to read from both stdout and stderr, whilst in addition writing to stdin and ensure that the output can be matched up with the inputs. Is there a workaround for windows to overcome this deficiency?
2 Answers
You are not very detailed on what is not working for you with stream-select on Windows. However, this is a working example on how to use stream-select. I just ran this successfully with PHP 5.4 on Windows XP.
Edit: Uhhmmm.. Seems like it was non-working after all... Sry, testing some more here.. :)
Edit again:
So, I did some more experimenting on this, but unsuccessfully.
Maybe you should just let the processes speak TCP/UDP/IP to each other?
Another way forward (if you still want to use stdout/stdin/stderr in your process) might be to use proc_open with file handlers, so your process is writing to files, and then use something similar to unix' inotify, loading this stuff with the PHP DOTNET class: Is there anything like inotify on Windows? to detect changes to the files...? Just an idea...
Or maybe change to a unix-like os? ;) Ok, that's it for me tonight. Good night
6 Comments
stream_select in your example seems useless. It just reads from stdout and stderr pipes without actually looking into what is returned in $read_streams. This could block if child process is busy (or child wrote into stderr when you're waiting data on stdout)select does not work. But unix/linux it seems to work. Sorry for the effort for code that does not work.
stream_set_blockingreturns false :-(stderrfrom messages printed tostdout(by using some sort of regexp for example)?