相关疑难解决方法(0)

如何杀死nodejs中的childprocess?

使用shelljs创建了一个子进程

!/usr/bin/env node

require('/usr/local/lib/node_modules/shelljs/global');
   fs = require("fs");  
   var child=exec("sudo mongod &",{async:true,silent:true});

   function on_exit(){
        console.log('Process Exit');
        child.kill("SIGINT");
        process.exit(0)
    }

    process.on('SIGINT',on_exit);
    process.on('exit',on_exit);
Run Code Online (Sandbox Code Playgroud)

子进程仍在运行..杀死父进程后

shell child-process node.js

57
推荐指数
1
解决办法
6万
查看次数

标签 统计

child-process ×1

node.js ×1

shell ×1