Fix error handling in child.exec.

The old code could have clobbered the original error if the child process writes
to stderr; this commit ensures the original error, if any, is preserved.