aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/process/ctrl-c.md
blob: b880cf62c03c0480fee1e4ed5c286ea857cfbfcc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
---
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](/docs/api/utils) for more useful utilities.