CodeZettaInterview Hub

Node.js · Processes · Fresh / Intern · Comparison

child_process.spawn vs exec vs fork — differences?

Short Interview Answer

spawn streams stdio; exec buffers output (shell); fork is spawn specialized for Node modules with IPC.

Detailed Explanation

Prefer spawn/execFile without shell for safety. fork for CPU workers talking via messages.

Did you know this answer?