2012-02-16 91 views

回答

3

你可以尝试捕捉你的孩子SIGINT

// child.js 
process.on("SIGINT", function() { console.log("sigint caught") }); 

// parent.js 
var fork = require("child_process").fork, 
    child = fork(__dirname + "/child.js"); 

运行parent.js并按^C。您的child.js应该继续在后台运行。我不知道在child.js的使用期限内会产生什么影响。

下面是关于主题on the node.js mailing list的一个启发性的,尽管很老的讨论。

-1

您可以在父母中拨打childprocess.disconnect();或在子女中拨打process.disconnect();

+3

对于看这个的人来说,这是行不通的 – 2013-09-27 20:34:54