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, then delivers what happened on a later turn of the loop, as events on the ChildProcess it returned:'spawn','data'/'end'on thechild.stdout/child.stderrstreams (or the output written straight through understdio: 'inherit'),'exit','close'; a binary that cannot start is an'error'event. LIMITATION: the child has finished beforespawnreturns, so a long-running one blocks the caller and its output arrives as one chunk per stream.
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_
PIPE_ METHODS - The methods of a
ChildPipe, besides the EventEmitter ones. - 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).- pipe_
call