Fix stdout premature EOF

Wait until the goroutines for stdout and stderr have both finished
before closing stdin.

Fixes #3631

Signed-off-by: Andy Goldstein <agoldste@redhat.com>