Created a childprocess using 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);
Child process is still running .. after kill the parent process
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…