Communicating with your child
All instances of the ChildProcess
object extend EventEmitter
, exposing events useful for managing child data connections. Additionally, ChildProcess
objects expose some useful methods for interacting with children directly. Let's go through those now, beginning with attributes and methods:
child.connected
: When a child is disconnected from its parent viachild.disconnect()
, this flag will be set tofalse
.child.stdin
: This is aWritableStream
corresponding to the child's standard in.child.stdout
: This is aReadableStream
corresponding to the child's standard out.child.stderr
: This is aReadableStream
corresponding to the child's standard error.child.pid
: This is an integer representing the process ID (PID) assigned to the child process.child.kill
: This tries to terminate a child process, sending it an optional signal. If no signal is specified, the default isSIGTERM
(for more about signals, see http://unixhelp.ed.ac.uk/CGI/man-cgi?signal+7). While the method...