Utility type for any process from () with stdin, stdout, stderr all set to null or similar.
type
NullSubprocess
Referenced types
interface Subprocess<In extends SpawnOptions.Writable = SpawnOptions.Writable, Out extends SpawnOptions.Readable = SpawnOptions.Readable, Err extends SpawnOptions.Readable = SpawnOptions.Readable>
A process created by Bun.spawn.
This type accepts 3 optional type parameters which correspond to the stdio array from the options object. Instead of specifying these, you should use one of the following utility types instead:
- ReadableSubprocess (any, pipe, pipe)
- WritableSubprocess (pipe, any, any)
- PipedSubprocess (pipe, pipe, pipe)
- NullSubprocess (ignore, ignore, ignore)
- readonly exitCode: null | number
Synchronously get the exit code of the process
If the process hasn't exited yet, this will return
null - readonly exited: Promise<number>
The exit code of the process
The promise will resolve when the process exits
- readonly pid: number
The process ID of the child process
const { pid } = Bun.spawn({ cmd: ["echo", "hello"] }); console.log(pid); // 1234 - readonly readable: ReadableToIO<Out>
This returns the same value as Subprocess.stdout
It exists for compatibility with ReadableStream.pipeThrough
- readonly signalCode: null | Signals
Synchronously get the signal code of the process
If the process never sent a signal code, this will return
nullTo receive signal code changes, use the
onExitcallback.If the signal code is unknown, it will return the original signal code number, but that case should essentially never happen.
- readonly stdio: [null, null, null, ...number[]]
Access extra file descriptors passed to the
stdiooption in the options object. Disconnect the IPC channel to the subprocess. This is only supported if the subprocess was created with the
ipcoption.- @param exitCode
The exitCode to send to the process
This method will tell Bun to wait for this process to exit after you already called
unref().Before shutting down, Bun will wait for all subprocesses to exit by default
Get the resource usage information of the process (max RSS, CPU time, etc)
Only available after the process has exited
If the process hasn't exited yet, this will return
undefined- send(message: any): void;
Send a message to the subprocess. This is only supported if the subprocess was created with the
ipcoption, and is another instance ofbun.Messages are serialized using the JSC serialize API, which allows for the same types that
postMessage/structuredClonesupports. Before shutting down, Bun will wait for all subprocesses to exit by default
This method will tell Bun to not wait for this process to exit before shutting down.