首页 Node.js核心模块手册

参数说明

on(event, callback)  
event          事件名称  
callback(      回调事件 
   ?                根据事件规定,参考事件列表
)

事件列表


事件 示例 描述
close
childprocess.on("close", function(code, signal){});

输入输出终止,子进程退出时触发

code:子进程退出码,正常退出值为0,异常退出null signal:字符串,父进程关闭子进程发给子进程的名称

exit childprocess.on("exit", function(code, signal){});

子进程退出时触发

回调参值同上

error childprocess.on("error", function(err){}); 子进程开启失败时触发
disconnect childprocess.on("disconnect", function(){}); IPC通道关闭