veyron/examples/tunnel: Fix race in IO

When the shell command exits, stdout and stderr are closed, which means
that both stdout2outchan() and stderr2outchan() will report an error.
The problem happens when there is still data to be read from one file
descriptor when the error is detected on the other, which would drop the
unread data.

This change makes sure that all the queues are properly drained when an
error is reported, and adds new tests for common patterns.

Change-Id: Iaa636e768a6c890155cbdc9ed44e3a925cbe676c
6 files changed
tree: 844695acf639804e2ca8ff8011925706154c5e4b
  1. examples/
  2. lib/
  3. products/
  4. runtimes/
  5. security/
  6. services/
  7. tools/