javascript - NodeJS:产生子进程,并捕获孙进程的标准输出?
问题描述
我正在尝试使用 NodeJS 启动一个进程child_process
,并且该进程本身会产生另一个进程。我正在尝试捕获孙进程标准输出或检测它正在关闭。出现了几个问题。
- 我的程序不知道可执行文件的文件名。(无法使用任务列表)
- 子进程在启动孙进程后立即关闭。
const spawn = require('child_process').spawn;
let childProcess = spawn('pathToExe', ['exeArgs'], {stdio: 'pipe'});
childProcess.stdout.on('data', (data) => {
// Here I can capture the child process STDOUT
// The child process closes instantly after spawning the 'grandchild'
});
如何查看子进程产生的子进程,并检测它何时关闭或退出?
解决方案
推荐阅读
- vuejs3 - Vue3在构建后在img上得到404,但在服务上工作
- html - Rails 未经允许的参数仍在保存对象
- android - android studios 中的 Anko toast - 未解决的参考。以下候选人均不适用
- javascript - 在匿名函数 .on 中使用变量
- javascript - JavaScript Array 删除数组中的开始引号和结束引号
- c# - 从访问 C# 表单绑定 DateTime
- matplotlib - 如何在 Python matplotlib.pyplot 中更改异常点符号
- jestjs - 检查 Playwright 和 Jest 中的浏览器控制台消息和响应状态代码
- python - 在 Python 中连接数千个数据帧的最有效方法是什么?
- java - 当我再次打开片段时,快照侦听器返回空快照