'spawn' 事件


一旦子进程衍生成功,则会触发 'spawn' 事件。 如果子进程没有衍生成功,则不会触发 'spawn' 事件,而是触发 'error' 事件。

如果触发,则 'spawn' 事件在所有其他事件之前,且在通过 stdoutstderr 接收任何数据之前。

无论在衍生的进程内是否发生错误,'spawn' 事件都会触发。 例如,如果 bash some-command 衍生成功,则 'spawn' 事件将触发,尽管 bash 可能衍生 some-command 失败。 当使用 { shell: true } 时,此注意事项也适用。

The 'spawn' event is emitted once the child process has spawned successfully. If the child process does not spawn successfully, the 'spawn' event is not emitted and the 'error' event is emitted instead.

If emitted, the 'spawn' event comes before all other events and before any data is received via stdout or stderr.

The 'spawn' event will fire regardless of whether an error occurs within the spawned process. For example, if bash some-command spawns successfully, the 'spawn' event will fire, though bash may fail to spawn some-command. This caveat also applies when using { shell: true }.