UtilityProcess

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
var pid: Double?

A Integer | undefined representing the process identifier (PID) of the child process. If the child process fails to spawn due to errors, then the value is undefined. When the child process exits, then the value is undefined after the exit event is emitted.

Link copied to clipboard

A NodeJS.ReadableStream | null that represents the child process's stderr. If the child was spawned with options.stdio2 set to anything other than 'pipe', then this will be null. When the child process exits, then the value is null after the exit event is emitted.

Link copied to clipboard

A NodeJS.ReadableStream | null that represents the child process's stdout. If the child was spawned with options.stdio1 set to anything other than 'pipe', then this will be null. When the child process exits, then the value is null after the exit event is emitted.

Functions

Link copied to clipboard
fun addListener(event: UtilityProcessEvent.EXIT, listener: (code: Double) -> Unit)
fun addListener(event: UtilityProcessEvent.MESSAGE, listener: (message: Any?) -> Unit)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun kill(): Boolean

Terminates the process gracefully. On POSIX, it uses SIGTERM but will ensure the process is reaped on exit. This function returns true if the kill is successful, and false otherwise.

Link copied to clipboard
fun off(event: UtilityProcessEvent.EXIT, listener: (code: Double) -> Unit)
fun off(event: UtilityProcessEvent.MESSAGE, listener: (message: Any?) -> Unit)
fun off(event: UtilityProcessEvent.SPAWN, listener: Function<Unit>)
Link copied to clipboard
fun on(event: UtilityProcessEvent.EXIT, listener: (code: Double) -> Unit)

Emitted after the child process ends.

fun on(event: UtilityProcessEvent.MESSAGE, listener: (message: Any?) -> Unit)

Emitted when the child process sends a message using process.parentPort.postMessage().

fun on(event: UtilityProcessEvent.SPAWN, listener: Function<Unit>)

Emitted once the child process has spawned successfully.

Link copied to clipboard
fun once(event: UtilityProcessEvent.EXIT, listener: (code: Double) -> Unit)
fun once(event: UtilityProcessEvent.MESSAGE, listener: (message: Any?) -> Unit)
Link copied to clipboard
fun postMessage(message: Any?, transfer: ReadonlyArray<MessagePortMain> = definedExternally)

Send a message to the child process, optionally transferring ownership of zero or more MessagePortMain objects.

Link copied to clipboard
fun removeListener(event: UtilityProcessEvent.EXIT, listener: (code: Double) -> Unit)
fun removeListener(event: UtilityProcessEvent.MESSAGE, listener: (message: Any?) -> Unit)
Link copied to clipboard