process.stderr.on('data') 和 process.on('error') 有什么区别?
What is the difference between process.stderr.on('data') and process.on('error')?
我正在为我的节点应用程序中的子进程设置错误处理,我想知道这两个选项:
childProcess.on('error', err => {
// omitted
});
// do we need both this and the preceding handler?
childProcess.stderr.on('data', data => {
// omitted
});
有什么区别?两者都需要吗?
当节点在启动、停止或管理子进程时出现问题时会触发 child process error
event。
stderr
is one of the output channels for the child process once it's running. The data
event can be fired many times in normal operation of a process and can often include important information about error conditions of the process. You would normally handle stdout
与 stderr
类似。
exit
events code
值对于子进程也很重要。进程通常会以非 0
return 代码退出,以表示发生了问题。
我正在为我的节点应用程序中的子进程设置错误处理,我想知道这两个选项:
childProcess.on('error', err => {
// omitted
});
// do we need both this and the preceding handler?
childProcess.stderr.on('data', data => {
// omitted
});
有什么区别?两者都需要吗?
当节点在启动、停止或管理子进程时出现问题时会触发 child process error
event。
stderr
is one of the output channels for the child process once it's running. The data
event can be fired many times in normal operation of a process and can often include important information about error conditions of the process. You would normally handle stdout
与 stderr
类似。
exit
events code
值对于子进程也很重要。进程通常会以非 0
return 代码退出,以表示发生了问题。