ChildProcessByStdio

sealed external interface ChildProcessByStdio<I : Writable?, O : Readable?, E : Readable?> : ChildProcess(source)

Properties

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

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

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

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

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
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

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

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

Link copied to clipboard
open var stderr: Readable?

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

Link copied to clipboard
open var stdin: Writable?

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

Link copied to clipboard

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 var stdout: Readable?

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

Functions

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

events.EventEmitter

fun addListener(event: ChildProcessEvent.CLOSE, listener: (code: Double?, signal: Signals?) -> Unit)
fun addListener(event: ChildProcessEvent.DISCONNECT, listener: () -> Unit)
fun addListener(event: ChildProcessEvent.ERROR, listener: (JsError) -> Unit)
fun addListener(event: ChildProcessEvent.EXIT, listener: (code: Double?, signal: Signals?) -> Unit)
fun addListener(event: ChildProcessEvent.SPAWN, listener: () -> Unit)
Link copied to clipboard

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
fun emit(event: Symbol, vararg args: Any?): Boolean
fun emit(event: String, vararg args: Any?): Boolean
fun emit(event: ChildProcessEvent.SPAWN, listener: () -> Unit): Boolean
fun emit(event: ChildProcessEvent.CLOSE, code: Double?, signal: Signals?): Boolean
fun emit(event: ChildProcessEvent.EXIT, code: Double?, signal: Signals?): Boolean
fun emit(event: ChildProcessEvent.MESSAGE, message: Serializable, sendHandle: SendHandle): Boolean
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

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

Link copied to clipboard
fun kill(): Boolean
fun kill(signal: Double = definedExternally): Boolean
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
fun on(event: String, listener: Function<Unit>)
fun on(event: ChildProcessEvent.CLOSE, listener: (code: Double?, signal: Signals?) -> Unit)
fun on(event: ChildProcessEvent.DISCONNECT, listener: () -> Unit)
fun on(event: ChildProcessEvent.ERROR, listener: (JsError) -> Unit)
fun on(event: ChildProcessEvent.EXIT, listener: (code: Double?, signal: Signals?) -> Unit)
fun on(event: ChildProcessEvent.SPAWN, listener: () -> Unit)
Link copied to clipboard
fun once(event: String, listener: Function<Unit>)
fun once(event: ChildProcessEvent.CLOSE, listener: (code: Double?, signal: Signals?) -> Unit)
fun once(event: ChildProcessEvent.DISCONNECT, listener: () -> Unit)
fun once(event: ChildProcessEvent.ERROR, listener: (JsError) -> Unit)
fun once(event: ChildProcessEvent.EXIT, listener: (code: Double?, signal: Signals?) -> Unit)
fun once(event: ChildProcessEvent.SPAWN, listener: () -> Unit)
Link copied to clipboard
fun prependListener(event: String, listener: Function<Unit>)
fun prependListener(event: ChildProcessEvent.CLOSE, listener: (code: Double?, signal: Signals?) -> Unit)
fun prependListener(event: ChildProcessEvent.EXIT, listener: (code: Double?, signal: Signals?) -> Unit)
fun prependListener(event: ChildProcessEvent.SPAWN, listener: () -> Unit)
Link copied to clipboard
fun prependOnceListener(event: String, listener: Function<Unit>)
fun prependOnceListener(event: ChildProcessEvent.CLOSE, listener: (code: Double?, signal: Signals?) -> Unit)
fun prependOnceListener(event: ChildProcessEvent.EXIT, listener: (code: Double?, signal: Signals?) -> Unit)
fun prependOnceListener(event: ChildProcessEvent.SPAWN, listener: () -> Unit)
Link copied to clipboard
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
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.

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

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
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.