Expand description
Node child_process module — real subprocess execution via
std::process::Command.
The synchronous entry points (execSync, spawnSync, execFileSync) are
fully implemented: they spawn the child with piped stdio, wait for it, and
return its captured output. stdout/stderr are returned as Buffers by
default (built through buffer::from_bytes, identical to the fs module’s
byte returns) or as strings when an encoding other than "buffer" is
given in the options object.
The asynchronous forms are backed synchronously here because node-js has no socket-driven child event loop:
exec(cmd, cb)runs the command to completion, then delivers the result through its callback(error, stdout, stderr)scheduled as a microtask (queue_micro), matching Node’s “callback fires after the current tick” ordering.stdout/stderrare strings, as Node’sexecdefault.execFile(file, args, cb)isexecwithout a shell —fileis run directly with theargsarray — and additionally returns a (non-live) ChildProcess-shaped object carrying the collected result.spawn(cmd, args)runs the command to completion up front and returns a minimal ChildProcess-shaped object carrying the already-collectedpid,exitCode,stdoutandstderr. LIMITATION: because these run synchronously, the returned object is not live —.on('close'|'exit', …)listeners registered by the caller after the call do not fire (the process has already finished and its output is exposed as properties).
fork(modulePath) is the exception: it spawns THIS node executable on
modulePath as a genuinely live child and returns a live ChildProcess
emitter that fires exit/close when the process terminates and supports
.kill(). Its IPC channel (.send() / process.on('message')) is NOT
implemented — see the fork fn doc for why.
Constants§
- CHILD_
PROCESS_ METHODS - Instance method names for the
ChildProcess@@nativetag, exposed tostdlib::instance_has_method(property reads that yield a bound method). - METHODS
Functions§
- call
- instance_
call stdlib::instance_callentry for aChildProcessreceiver. EventEmitter methods delegate toevents; process-control methods act on the live child (onlyforked children are live — aspawn/execFileresult has already exited, sokillis a no-op there).