I do have a node application that starts one. I am using the spawn()
method instead of fork()
to create the child instance because I sometimes need to start the child process using different node command line arguments (e.g. debug).
Consider the following example:
master.js
var child = require("child_process").spawn("node", ["child"]);
child.stdout.pipe(process.stdout, { end: false });
child.js
console.log("Hello World!");
console.log(require("util").format("Hello World2!"));
setTimeout(function(){
console.log("Error!");
console.log(require("util").format("Error2!"));
process.exit(1);
},2000);
When running master.js (on windows) the actual output is
Hello World!
Hello World2!
Error!
The "Error2!" message is missing and I don't understand why. Do you have any idea what's going wrong here?
Thanks in advance!