Files
bun.sh/docs/guides/process/os-signals.mdx
Ryan Machado 64146d47f9 Update os-signals.mdx (#25372)
### What does this PR do?

Remove a loose section from os-signals documentation

### How did you verify your code works?

Just a small documentation change.

Co-authored-by: Michael H <git@riskymh.dev>
2025-12-10 16:06:39 +11:00

32 lines
725 B
Plaintext

---
title: Listen to OS signals
sidebarTitle: OS signals
mode: center
---
Bun supports the Node.js `process` global, including the `process.on()` method for listening to OS signals.
```ts
process.on("SIGINT", () => {
console.log("Received SIGINT");
});
```
---
If you don't know which signal to listen for, you listen to the [`"beforeExit"`](https://nodejs.org/api/process.html#event-beforeexit) and [`"exit"`](https://nodejs.org/api/process.html#event-exit) events.
```ts
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](/runtime/utils) for more useful utilities.