在cmd中运行Node程序,ctrl+c/关闭cmd窗口,Node.js中能捕获到吗?
回复 (6)
Y
ctrl+c肯定可以的.
A
process.on('SIGTERM', function(){});
process.on('SIGINT', function(){});
T
可以。增加end的监听
B
B
A
引用 bcpxqzhttps://github.com/shigeki/node/commit/e669cef62cefcfbac9417ff31da0644c271336af https://github.c...
确实. windows 下似乎只能用鸡肋 process.on('exit', function(){})
就 ctrl + c 来说已有替代方案
参与回复
登录后即可参与回复。登录