SpawnedProcess
Defined in: packages/node/src/process/spawned-process.ts:51
A running child process: its output as events, its exit as an awaitable, and a two-stage termination.
Obtained from startProcess or forkProcess, both of which resolve only
once the child has actually spawned — so a handle always has a pid, and a
spawn failure surfaces as a rejection there rather than later on the handle.
Line splitting is attached on the first output subscription, so a caller
that only wants the exit status never pays for it.
Extends
Section titled “Extends”EventDispatcherMapBase<TEvents>
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”TEvents
Section titled “TEvents”TEvents extends SpawnedProcessEvents & Record<PropertyKey, unknown[]> = SpawnedProcessEvents
Implements
Section titled “Implements”IEventDispatcherMap<TEvents>AsyncDisposable
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SpawnedProcess<
TEvents>(child,startedAt,options?):SpawnedProcess<TEvents>
Defined in: packages/node/src/process/spawned-process.ts:68
Parameters
Section titled “Parameters”ChildProcess
startedAt
Section titled “startedAt”number
options?
Section titled “options?”Returns
Section titled “Returns”SpawnedProcess<TEvents>
Overrides
Section titled “Overrides”EventDispatcherMapBase<TEvents>.constructor
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get pid():
number|undefined
Defined in: packages/node/src/process/spawned-process.ts:85
Returns
Section titled “Returns”number | undefined
stderr
Section titled “stderr”Get Signature
Section titled “Get Signature”get stderr():
ReadableStream<Uint8Array<ArrayBufferLike>> |null
Defined in: packages/node/src/process/spawned-process.ts:96
The child’s standard error, null unless it was piped.
Returns
Section titled “Returns”ReadableStream<Uint8Array<ArrayBufferLike>> | null
stdout
Section titled “stdout”Get Signature
Section titled “Get Signature”get stdout():
ReadableStream<Uint8Array<ArrayBufferLike>> |null
Defined in: packages/node/src/process/spawned-process.ts:90
The child’s standard output, null unless it was piped.
Returns
Section titled “Returns”ReadableStream<Uint8Array<ArrayBufferLike>> | null
Methods
Section titled “Methods”[asyncDispose]()
Section titled “[asyncDispose]()”[asyncDispose]():
Promise<void>
Defined in: packages/node/src/process/spawned-process.ts:189
Returns
Section titled “Returns”Promise<void>
Implementation of
Section titled “Implementation of”AsyncDisposable.[asyncDispose]
isSubscribed()
Section titled “isSubscribed()”isSubscribed<
K>(event,listener):boolean
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:38
Check if a callback is subscribed to a specific event.
Type Parameters
Section titled “Type Parameters”K extends string | number | symbol
Parameters
Section titled “Parameters”K
The event name.
listener
Section titled “listener”Callable<TEvents[K]>
The callback to check.
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”IEventDispatcherMap.isSubscribed
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.isSubscribed
kill()
Section titled “kill()”kill(
signal?):boolean
Defined in: packages/node/src/process/spawned-process.ts:185
Sends one signal and returns, with no escalation — for signals that mean something to the child other than “shut down”.
Parameters
Section titled “Parameters”signal?
Section titled “signal?”Signals = "SIGTERM"
Defaults to SIGTERM.
Returns
Section titled “Returns”boolean
Whether the signal was delivered.
subscribe()
Section titled “subscribe()”subscribe<
K>(event,listener,options?):Callable|null
Defined in: packages/node/src/process/spawned-process.ts:111
Type Parameters
Section titled “Type Parameters”K extends string | number | symbol
Parameters
Section titled “Parameters”K
listener
Section titled “listener”Callable<TEvents[K]>
options?
Section titled “options?”EventDispatcherSubscribeOptions
Returns
Section titled “Returns”Callable | null
Implementation of
Section titled “Implementation of”IEventDispatcherMap.subscribe
Overrides
Section titled “Overrides”EventDispatcherMapBase.subscribe
terminate()
Section titled “terminate()”terminate(
graceMs?):Promise<ProcessExit>
Defined in: packages/node/src/process/spawned-process.ts:160
Sends SIGTERM, then SIGKILL if the child is still alive after
graceMs. Idempotent: concurrent and repeated calls share one escalation.
Parameters
Section titled “Parameters”graceMs?
Section titled “graceMs?”number
Overrides the grace period given at spawn time.
Returns
Section titled “Returns”Promise<ProcessExit>
The child’s exit, once it has happened.
unsubscribe()
Section titled “unsubscribe()”unsubscribe<
K>(event,listener):void
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:31
Unsubscribe a callback from a specific event.
Type Parameters
Section titled “Type Parameters”K extends string | number | symbol
Parameters
Section titled “Parameters”K
The event name.
listener
Section titled “listener”Callable<TEvents[K]>
The callback to remove.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IEventDispatcherMap.unsubscribe
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.unsubscribe
wait()
Section titled “wait()”wait<
K>(event,options?):Promise<TEvents[K]>
Defined in: packages/node/src/process/spawned-process.ts:120
Type Parameters
Section titled “Type Parameters”K extends string | number | symbol
Parameters
Section titled “Parameters”K
options?
Section titled “options?”EventDispatcherWaitOptions<TEvents[K]>
Returns
Section titled “Returns”Promise<TEvents[K]>
Implementation of
Section titled “Implementation of”IEventDispatcherMap.wait
Overrides
Section titled “Overrides”EventDispatcherMapBase.wait
waitForExit()
Section titled “waitForExit()”waitForExit(
signal?):Promise<ProcessExit>
Defined in: packages/node/src/process/spawned-process.ts:134
Resolves once the child has exited, immediately if it already has.
Parameters
Section titled “Parameters”signal?
Section titled “signal?”AbortSignal | null
Abandons the wait; the child is left running.
Returns
Section titled “Returns”Promise<ProcessExit>
The exit code, terminating signal and wall-clock duration.