More sensible interleaving of the reading/writing to the child process.

This was hoped to solve a problem on Linux, which it doesn't; but it is more
sensible full stop, as it means that poll is likely to return less often, and
the code is somewhat cleaner.