child_process: add safety checks on stdio accesses

When a child process is spawned, there is [no guarantee](https://github.com/joyent/node/blob/master/lib/child_process.js#L1124-L1136) that the stdio streams will be created. This commit adds checks before attempting to access the streams.