Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
Listen to OS signals - Bun
[go: Go Back, main page]

Skip to main content
Bun supports the Node.js process global, including the process.on() method for listening to OS signals.
process.on("SIGINT", () => {
  console.log("Received SIGINT");
});

If you don’t know which signal to listen for, you listen to the "beforeExit" and "exit" events.
process.on("beforeExit", code => {
  console.log(`Event loop is empty!`);
});

process.on("exit", code => {
  console.log(`Process is exiting with code ${code}`);
});

See Docs > API > Utils for more useful utilities.