Handle output from PT processes with the event loop
Currently the output from stdout/stderr of a PT process is only read during the startup of the process. The reading process uses read() on a non-blocking socket, which currently seems to work, but have proved to be flaky.
We should ensure that PT processes' output can be read all the time.
On Windows we cannot attach the pipes to the main loop because of limitations of the
select() API, so we have to do something slightly worse such as reading from the stdout/stderr handle via a timer as long as the processes are alive.