say that resources between processes cannot be shared? even if you want to share, you need to use the manual of process communication, right?
individuals only go so far in sharing resources between processes.
so why can the processes created by Node.js child_process take the data of the parent process between them?
//
const exec = require("child_process").exec;
const Name = "QQ";
exec("echo hello world", (err, stdout, stderr) => {
if (err) throw err;
console.log (Name); // "QQ"
})
Why can the Name variable of the main process be obtained in the callback of exec? Is it possible that the callback function of exec is back to the parent process?
by the way, my parent process had a function that uniformly handles error. I can capture and process the throw of all the main processes.
but once throw error is in exec. My main process can"t be captured, and the main process is dead.