What is the Windows equivalent of process.on('SIGINT') in node.js?

前端 未结 6 1327
北海茫月
北海茫月 2020-11-28 02:47

I\'m following the guidance here (listening for SIGINT events) to gracefully shutdown my Windows-8-hosted node.js application in response to Ctrl+

6条回答
  •  抹茶落季
    2020-11-28 03:46

    Nowadays it just works on all platforms, including Windows.

    The following code logs and then terminates properly on Windows 10:

    process.on('SIGINT', () => {
        console.log("Terminating...");
        process.exit(0);
    });
    

提交回复
热议问题