child_process 6.9.1版本 stdout 被占用导致 回调迟迟没有退出

The 'close' event is emitted when the stdio streams of a child process have been closed. This is distinct from the 'exit' event, since multiple processes might share the same stdio streams.

这句话是说 stdio 关闭后才会触发close事件  


应用场景分析:child_process.exec调用了脚本a.sh,a.sh 调用脚本b.sh  b.sh 中 使用了  expect 命令 ,spawn命令启动了进程安装hadoop。


问题描述:安装结束,没有处罚close事件,stdio被占用,回调迟迟没有退出!


处理办法:通过exit事件 判断进程结束,在exit事件的回调中 通过错误码判断是否异常退出。

chboot.on("exit", function(code, signal) {
    console.warn("TMP boot exit: " + code + ", " + signal);
    chboot.stdin.end();

    if (g_installStatus.bIsComplete == false) {
        g_installStatus.bIsComplete = true;
        g_installStatus['installRes'].status = true;

        if (code == 0) {
            g_installStatus['installRes'].detail = bout;
        } else {
            g_installStatus['installRes'].detail = berr;
        }
    }

    setTimeout(function() {
        g_isInstallUpdate = false;
    }, 10*1000);
});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值