ChildProcessWithoutNullStreams
Properties
The subprocess.signalCode
property indicates the signal received by the child process if any, else null
.
The subprocess.spawnargs
property represents the full list of command-line arguments the child process was launched with.
A sparse array of pipes to the child process, corresponding with positions in the stdio
option passed to {@link spawn} that have been set to the value 'pipe'
. subprocess.stdio[0]
, subprocess.stdio[1]
, and subprocess.stdio[2]
are also available as subprocess.stdin
, subprocess.stdout
, and subprocess.stderr
, respectively.
Functions
events.EventEmitter
Alias for emitter.on(eventName, listener)
.
Closes the IPC channel between parent and child, allowing the child to exit gracefully once there are no other connections keeping it alive. After calling this method the subprocess.connected
and process.connected
properties in both the parent and child (respectively) will be set to false
, and it will be no longer possible to pass messages between the processes.
Synchronously calls each of the listeners registered for the event named eventName
, in the order they were registered, passing the supplied arguments to each.
Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbol
s.
Returns the current max listener value for the EventEmitter
which is either set by emitter.setMaxListeners(n)
or defaults to {@link defaultMaxListeners}.
Returns the number of listeners listening for the event named eventName
. If listener
is provided, it will return how many times the listener is found in the list of the listeners of the event.
Returns a copy of the array of listeners for the event named eventName
.
Alias for emitter.removeListener()
.
Adds the listener
function to the end of the listeners array for the event named eventName
. No checks are made to see if the listener
has already been added. Multiple calls passing the same combination of eventName
and listener
will result in the listener
being added, and called, multiple times.
Adds the listener
function to the beginning of the listeners array for the event named eventName
. No checks are made to see if the listener
has already been added. Multiple calls passing the same combination of eventName
and listener
will result in the listener
being added, and called, multiple times.
Adds a one-timelistener
function for the event named eventName
to the beginning of the listeners array. The next time eventName
is triggered, this listener is removed, and then invoked.
Returns a copy of the array of listeners for the event named eventName
, including any wrappers (such as those created by .once()
).
Removes all listeners, or those of the specified eventName
.
Removes the specified listener
from the listener array for the event named eventName
.
When an IPC channel has been established between the parent and child ( i.e. when using {@link fork}), the subprocess.send()
method can be used to send messages to the child process. When the child process is a Node.js instance, these messages can be received via the 'message'
event.
By default EventEmitter
s will print a warning if more than 10
listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners()
method allows the limit to be modified for this specific EventEmitter
instance. The value can be set to Infinity
(or 0
) to indicate an unlimited number of listeners.
By default, the parent will wait for the detached child to exit. To prevent the parent from waiting for a given subprocess
to exit, use the subprocess.unref()
method. Doing so will cause the parent's event loop to not include the child in its reference count, allowing the parent to exit independently of the child, unless there is an established IPC channel between the child and the parent.