use a "self-pipe" to handle cmd timeouts

This switches to defining a stop "self-pipe" for signaling when the
child process has exited.  Intead of looping in the `wait_for_exit`
and checking if you've timed out every `WAIT_INTERVAL`, you instead
just select on the stop pipe with a timeout (or not).  The thread
streaming the child process output also checks if the child process
has exited.  If it has the stream thread writes to the stop pipe
which triggers the wait to end.