So I have an array of child processes in my NodeJs application. Now I have

cp_array[i].process.on("exit",exithandle(code,signal));

On each of them. The problem is I want to be able to access the process object of the process that exited in the exithandle. So if I'd put like cp_array[i].process.name="example" I'd be able to access my "example" string with process.name within the exithandle function.

share|improve this question

76% accept rate
feedback

1 Answer

You can access cp_array[i].process through the this keyword:

function exithandle(code, signal) {
    var process = this;
    return function() {
        // Whatever
    };
}
share|improve this answer
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.