Skip to content

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.

  • EventDispatcherMapBase<TEvents>

TEvents extends SpawnedProcessEvents & Record<PropertyKey, unknown[]> = SpawnedProcessEvents

  • IEventDispatcherMap<TEvents>
  • AsyncDisposable

new SpawnedProcess<TEvents>(child, startedAt, options?): SpawnedProcess<TEvents>

Defined in: packages/node/src/process/spawned-process.ts:68

ChildProcess

number

SpawnedProcessOptions

SpawnedProcess<TEvents>

EventDispatcherMapBase<TEvents>.constructor

get pid(): number | undefined

Defined in: packages/node/src/process/spawned-process.ts:85

number | undefined


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.

ReadableStream<Uint8Array<ArrayBufferLike>> | null


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.

ReadableStream<Uint8Array<ArrayBufferLike>> | null

[asyncDispose](): Promise<void>

Defined in: packages/node/src/process/spawned-process.ts:189

Promise<void>

AsyncDisposable.[asyncDispose]


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.

K extends string | number | symbol

K

The event name.

Callable<TEvents[K]>

The callback to check.

boolean

IEventDispatcherMap.isSubscribed

EventDispatcherMapBase.isSubscribed


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

Signals = "SIGTERM"

Defaults to SIGTERM.

boolean

Whether the signal was delivered.


subscribe<K>(event, listener, options?): Callable | null

Defined in: packages/node/src/process/spawned-process.ts:111

K extends string | number | symbol

K

Callable<TEvents[K]>

EventDispatcherSubscribeOptions

Callable | null

IEventDispatcherMap.subscribe

EventDispatcherMapBase.subscribe


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.

number

Overrides the grace period given at spawn time.

Promise<ProcessExit>

The child’s exit, once it has happened.


unsubscribe<K>(event, listener): void

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:31

Unsubscribe a callback from a specific event.

K extends string | number | symbol

K

The event name.

Callable<TEvents[K]>

The callback to remove.

void

IEventDispatcherMap.unsubscribe

EventDispatcherMapBase.unsubscribe


wait<K>(event, options?): Promise<TEvents[K]>

Defined in: packages/node/src/process/spawned-process.ts:120

K extends string | number | symbol

K

EventDispatcherWaitOptions<TEvents[K]>

Promise<TEvents[K]>

IEventDispatcherMap.wait

EventDispatcherMapBase.wait


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.

AbortSignal | null

Abandons the wait; the child is left running.

Promise<ProcessExit>

The exit code, terminating signal and wall-clock duration.