Tweak select wakeup logic
This resets the wakeup state machine only after draining the pipe which can
avoid a state transition in case a wakeup is called before clearing the state
and allow select to be entered sooner.
This also reads more than single byte from the pipe to try to heal after a
`fork` followed by child process(es) writing to the pipe, which can only happen
in a single domain program.