child_process: add safety checks on stdio access
When a child process is spawned, there is no guarantee that stdout
and stderr
will be created successfully. This commit adds checks before attempting to access the streams.
This is related to https://github.com/nodejs/node/issues/1321. It prevents Node from synchronously throwing TypeError: Cannot read property 'addListener' of undefined
. Instead, an async error, EAGAIN
is provided to the callback.