In my program I have saveral pipes which are connected to stdout and stderr streams of child processes (i.e. in main process I’m reading from this streams). But when there is nothing to read from one of them my program hangs. Is there way to solve this problem not using thread. Also I want all child processes to be killed if there is nothing to read during x msecs.
In unix select() + non_blocking read solves this two problems. But what about windows?
You can use a similar approach in windows. Using OVERLAPPED structs, you can issue asynchronous I/O against the pipes. Then use WaitForMultipleObjects on the associated event handles with a timeout (this is the select analog). See this for an overview of the options.