Expand description
bun_spawn — process-spawn implementation extracted from
src/runtime/api/bun/process.zig so that bun_install, bun_jsc, and
bun_patch can construct/track child processes without depending on
bun_runtime (cycle: bun_runtime → bun_install/bun_jsc).
LAYERING: this crate owns the spawn implementation (not just data
shapes). Process, Poller, WaiterThread, spawn_process, and
sync::spawn were MOVED DOWN here from bun_runtime::api::bun::process;
bun_runtime re-exports them. The only non-leaf dependencies are
bun_io (FilePoll/KeepAlive/EventLoopCtx), bun_ptr
(ThreadSafeRefCount), bun_io (BufferedWriter), bun_event_loop,
bun_threading, and bun_crash_handler — none of which depend back on
this crate, so no cycle.
Zig source of truth: src/runtime/api/bun/process.zig,
src/runtime/api/bun/spawn.zig,
src/runtime/api/bun/subprocess/StaticPipeWriter.zig.
Re-exports§
pub use process::Exited;pub use process::Poller;pub use process::Process;pub use process::SignalCodeExt;pub use process::SpawnOptions;pub use process::SpawnProcessResult;pub use process::SpawnResultExt;pub use process::Status;pub use process::WaiterThread;pub use process::spawn_process;pub use bun_sys as spawn_sys;
Modules§
- ffi
- posix_
spawn - posix_spawn(2) FFI wrappers (Actions / Attr / spawn_z / wait4).
MOVE_DOWN: implementation now lives in
bun_spawn_sys; re-exported here with the higher-tierprocess::*glue (Process/Status/spawn_process/sync) restored so existingbun_spawn::posix_spawn::bun_spawn::*paths keep resolving. - process
Process/Poller/WaiterThread/spawn_process/sync/Status/SpawnOptions/SpawnResult. Port ofsrc/runtime/api/bun/process.zig.- static_
pipe_ writer - Generic
StaticPipeWriter<P>(jsc.Subprocess.NewStaticPipeWriter). Port ofsrc/runtime/api/bun/subprocess/StaticPipeWriter.zig. - subprocess
- sync
bun.spawnSync(process.zigpub const sync).
Macros§
Structs§
- Dup2
- Posix
Spawn Options - Posix
Spawn Result - Process
Exit - RunOptions
- Options for
run— port ofstd.process.Child.RunOptions(subset used byrepository.zig). - RunResult
- Result of
run— port ofstd.process.Child.RunResult. - Wait
PidResult posix_spawn::WaitPidResult— re-exported frombun_spawn_sys.statusisu32there (Zigc_intreinterpreted via theW*macros);Status::fromcasts before matching.
Enums§
- Event
Loop Handle - Extra
Pipe - Entry in
extra_pipesfor a stdio slot at index >= 3. - Process
Exit Kind - Stdio
- Stdio
Kind bun.jsc.Subprocess.StdioKind— defined here (not insubprocess) to keep the spawn-sys layer leaf. Re-exported up throughbun_spawn::process→bun_runtime::api::{bun_process, JscSubprocess}→shell::subproc.- Term
- Port of
std.process.Child.Term.
Traits§
- Rusage
Fields - Platform-uniform field accessors over
Rusage. The underlying alias has divergent field names (ru_*on every Unixlibc::rusage; bare names onWinRusagewith severalu0/absent counters). This trait gives JS-facing getters one cfg-free body, matching the Zig spec’s uniform names.
Functions§
- run
- Port of
std.process.Child.run— blocking spawn that captures stdout/stderr.
Type Aliases§
- Argv
[*:null]?[*:0]const u8— null-terminated array of NUL-terminated C strings (theargvshapeposix_spawn/execveaccept). Build asVec<*const c_char>with a trailingcore::ptr::null(), then.as_ptr().- CStrPtr
- Element type for an owned
Vecbacking anArgv/Envp. Null is the sentinel; never wrap inOption. - Envp
- Same shape as
Argvfor the environment block. - ExtraFd
- Alias for the per-extra-fd Stdio entry passed in
SpawnOptions::extra_fds. - PidT
- Process
Exit Handler None= no handler set (the default forProcess::exit_handler).- Rusage
- Spawn
Result