If a process filled up the buffer of the standard error pipe before closing the
standard output pipe, it would hang. As a result, the call to
stream_get_contents for the standard output pipe would not return, as the
standard error pipe needs to be read from in order for the process to continue.
This change uses stream_select to read from both pipes whenever data becomes
available.