Node.JS Exec Question:
I have a program which spawns multiple processes, and I’d like to log the order of the processes finishing by capturing the PID when the process finishes. From what I can tell the standard callbacks do not include the PID (stdout,stderr,and error).
I’d like to avoid using spawn, but it looks like I’ll have to, unless any kind souls have some ideas.
Thanks in advance.
EDIT:
To clarify:
var child = child_process.exec(..., function() {
console.log( child.pid );
});
will not work for multiple processes. This returns the last process, not the process which triggered the call back.
I highly suggest reading the documentation – you might find answers to all your questions there. 🙂
// EDIT If you are using a loop to create processes, then use it like that:
to avoid scoping issues.