The spawn() method returns streams (stdout &stderr) and it should be used when the process returns a volume amount of data. spawn() starts receiving the response as soon as the process starts executing.
The fork() Method
child_process.fork method is a special case of spawn() to create Node processes. It has the following signature −
child_process.fork(modulePath[, args][, options])
The fork method returns an object with a built-in communication channel in addition to having all the methods in a normal ChildProcess instance.
spawn()方法
child_process.spawn method launches a new process with a given command. It has the following signature −
Read more about options
The spawn() method returns streams (stdout &stderr) and it should be used when the process returns a volume amount of data. spawn() starts receiving the response as soon as the process starts executing.
The fork() Method
child_process.fork method is a special case of spawn() to create Node processes. It has the following signature −
The fork method returns an object with a built-in communication channel in addition to having all the methods in a normal ChildProcess instance.