> ## Documentation Index
> Fetch the complete documentation index at: https://bun.manicule.dev/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://bun.manicule.dev/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://bun.manicule.dev/api/mcp.
> Every agent surface: https://bun.manicule.dev/.well-known/llms-manifest.json

# Listen to OS signals (/guides/process/os-signals)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 157 · updated: 2026-08-02 -->
Related: [Parse command-line arguments](/guides/process/argv.md), [Listen for CTRL+C](/guides/process/ctrl-c.md), [Spawn a child process and communicate using IPC](/guides/process/ipc.md), [Get the process uptime in nanoseconds](/guides/process/nanoseconds.md), [Read stderr from a child process](/guides/process/spawn-stderr.md), [Read stdout from a child process](/guides/process/spawn-stdout.md)

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, listen for 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 [Utils](/runtime/utils) for more utilities.
