spawn()
The node:child_process function that starts a program with a list of arguments and gives you its standard input, output and error as streams.
In more detail
Arguments are passed directly to the program, not through a shell, so they cannot inject extra commands. Streaming the output keeps memory flat even for very large results.
Related terms
- child process — A process started by another process, its parent, from which it inherits a copy of the environment and current directory.
- execFile() — The node:child_process function that runs a program directly, without a shell, and buffers its output.
- command injection — An attack where input meant as data, such as a file name or form field, gets run as commands because a program built code from it.
- standard output and standard error — The two channels a program writes normal output (stdout) and error messages (stderr) to, plus stdin for input.
Taught in
- Child Processes: spawn, execFile, fork & IPC — Node.js Internals & Backend Services
- Global Error Trapping: uncaughtException & Exits — Node.js Internals & Backend Services