This makes one of the internal process_control tests go green. It covers the case where spawned process P1 itself spawns a child process C1, shared stdout/stderr file handles with C1, and then P1 terminates.
Prior to this change, we would end up timing out rather than detecting the immediate termination of P1 because we would wait for the stdout/stderr file handles to wrap up.
Now we wait on a condition variable that is set via a thread parked on subprocess.Popen.wait() and another on subprocess.Popen.communicate(). This allows us to catch the scenario above. There's an additional thread (for the thread parked on wait()). Both the wait() and the communicate() threads wait efficiently, so this should be minimal cost.