rembrembdocs

Skip to main content

Bun home pagelight logodark logo

[Runtime

](../../../index.md)[Package Manager

](../../../pm/cli/install/index.md)[Bundler

](../../../bundler/index.md)[Test Runner

](../../../test/index.md)[Guides

](../../index.md)[Reference

](https://bun.com/reference)[Blog

](https://bun.com/blog)[Feedback

](../../../feedback/index.md)

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.

Was this page helpful?

Suggest editsRaise issue

[

Listen for CTRL+C

Previous

](../ctrl-c/index.md)[

Get the process uptime in nanoseconds

Next

](../nanoseconds/index.md)