Javascript Node.js子进程,是否访问事件句柄中的进程对象?

Javascript Node.js子进程,是否访问事件句柄中的进程对象?,javascript,node.js,child-process,Javascript,Node.js,Child Process,因此,我在NodeJs应用程序中有一系列子进程。现在我有 cp_array[i].process.on("exit",exithandle(code,signal)); 在他们每个人身上。 问题是我希望能够访问exithandle中退出的进程的进程对象。因此,如果我想使用cp_数组[I].process.name=“example”,我就可以在exithandle函数中使用process.name访问我的“example”字符串。您可以通过this关键字访问cp_数组[I].process:

因此,我在NodeJs应用程序中有一系列子进程。现在我有

cp_array[i].process.on("exit",exithandle(code,signal));
在他们每个人身上。
问题是我希望能够访问exithandle中退出的进程的进程对象。因此,如果我想使用cp_数组[I].process.name=“example”,我就可以在exithandle函数中使用process.name访问我的“example”字符串。

您可以通过
this
关键字访问
cp_数组[I].process

function exithandle(code, signal) {
    var process = this;
    return function() {
        // Whatever
    };
}