ChildProcessByStdio

Properties

Link copied to clipboard
abstract external var boundStderr: E
Link copied to clipboard
abstract external var boundStdin: I
Link copied to clipboard
abstract external val boundStdio: Tuple5<I, O, E, Any?, Any?>
Link copied to clipboard
abstract external var boundStdout: O
Link copied to clipboard
external val channel: Control?

The subprocess.channel property is a reference to the child's IPC channel. If no IPC channel exists, this property is undefined.

Link copied to clipboard
Link copied to clipboard
external val connected: Boolean

The subprocess.connected property indicates whether it is still possible to send and receive messages from a child process. When subprocess.connected is false, it is no longer possible to send or receive messages.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
external val exitCode: Double?

The subprocess.exitCode property indicates the exit code of the child process. If the child process is still running, the field will be null.

Link copied to clipboard
Link copied to clipboard
external val killed: Boolean

The subprocess.killed property indicates whether the child process successfully received a signal from subprocess.kill(). The killed property does not indicate that the child process has been terminated.

Link copied to clipboard
Link copied to clipboard
external val pid: Double?

Returns the process identifier (PID) of the child process. If the child process fails to spawn due to errors, then the value is undefined and error is emitted.

Link copied to clipboard
external val signalCode: Signals?

The subprocess.signalCode property indicates the signal received by the child process if any, else null.

Link copied to clipboard

The subprocess.spawnargs property represents the full list of command-line arguments the child process was launched with.

Link copied to clipboard
Link copied to clipboard
external val spawnfile: String

The subprocess.spawnfile property indicates the executable file name of the child process that is launched.

Link copied to clipboard
open external var stderr: Readable?

A Readable Stream that represents the child process's stderr.

Link copied to clipboard
open external var stdin: Writable?

A Writable Stream that represents the child process's stdin.

Link copied to clipboard
open external val stdio: Tuple5<Writable?, Readable?, Readable?, Any?, Any?>

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.

Link copied to clipboard
open external var stdout: Readable?

A Readable Stream that represents the child process's stdout.

Functions

Link copied to clipboard
external fun addListener(event: String, listener: Function<Unit>)

events.EventEmitter

external fun addListener(type: EventType, listener: EventListener)

Alias for emitter.on(eventName, listener).

Link copied to clipboard
external fun disconnect()

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.

Link copied to clipboard
external fun emit(event: Symbol, vararg args: Any?): Boolean
external fun emit(event: String, vararg args: Any?): Boolean

external fun emit(type: EventType, vararg args: Any?): Boolean

Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

Link copied to clipboard

Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.

Link copied to clipboard
external fun getMaxListeners(): Double

Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to {@link EventEmitter.defaultMaxListeners}.

Link copied to clipboard
external fun kill(): Boolean
external fun kill(signal: Double = definedExternally): Boolean
external fun kill(signal: Signals = definedExternally): Boolean

The subprocess.kill() method sends a signal to the child process. If no argument is given, the process will be sent the 'SIGTERM' signal. See signal(7) for a list of available signals. This function returns true if kill(2) succeeds, and false otherwise.

Link copied to clipboard
external fun listenerCount(type: EventType, listener: EventListener = definedExternally): Double

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.

Link copied to clipboard

Returns a copy of the array of listeners for the event named eventName.

Link copied to clipboard
external fun off(type: EventType, listener: EventListener)

Alias for emitter.removeListener().

Link copied to clipboard
external fun on(event: String, listener: Function<Unit>)

external fun on(type: EventType, listener: EventListener)

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.

Link copied to clipboard
external fun once(event: String, listener: Function<Unit>)

external fun once(type: EventType, listener: EventListener)

Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

Link copied to clipboard
external fun prependListener(event: String, listener: Function<Unit>)

external fun prependListener(type: EventType, listener: EventListener)

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.

Link copied to clipboard
external fun prependOnceListener(event: String, listener: Function<Unit>)

external fun prependOnceListener(type: EventType, listener: EventListener)

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.

Link copied to clipboard

Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).

Link copied to clipboard
external fun ref()

Calling subprocess.ref() after making a call to subprocess.unref() will restore the removed reference count for the child process, forcing the parent to wait for the child to exit before exiting itself.

Link copied to clipboard
external fun removeAllListeners(type: EventType = definedExternally)

Removes all listeners, or those of the specified eventName.

Link copied to clipboard
external fun removeListener(type: EventType, listener: EventListener)

Removes the specified listener from the listener array for the event named eventName.

Link copied to clipboard
external fun send(message: Serializable, callback: (JsError?) -> Unit = definedExternally): Boolean

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.

external fun send(message: Serializable, sendHandle: SendHandle = definedExternally, callback: (JsError?) -> Unit = definedExternally): Boolean
external fun send(message: Serializable, sendHandle: SendHandle = definedExternally, options: MessageOptions = definedExternally, callback: (JsError?) -> Unit = definedExternally): Boolean
Link copied to clipboard
external fun setMaxListeners(n: Number)

By default EventEmitters 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.

Link copied to clipboard
external fun unref()

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.