Files
bun.sh/docs/guides/process/ctrl-c.md
2025-07-10 00:10:43 -07:00

17 lines
441 B
Markdown

---
name: Listen for CTRL+C
---
The `ctrl+c` shortcut sends an _interrupt signal_ to the running process. This signal can be intercepted by listening for the `SIGINT` event. If you want to close the process, you must explicitly call `process.exit()`.
```ts
process.on("SIGINT", () => {
console.log("Ctrl-C was pressed");
process.exit();
});
```
---
See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities.