Fix slow ssh

We break the read while loop after waiting "the end of the process" and
the pipes are empty, otherwise we do another select that waits all the
timeout.
See #5570. Replace pull #5839.

This patch passes @jctanner's test:
```for i in {1..100}; do rm test/*.pyc ; nosetests --tests=test/TestSSH.py; done```

@lukyanov, can you please test this?