2012-02-16 131 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