Skip to content
Bun
Bun
Processes & System

Listen for CTRL+C

The ctrl+c shortcut sends an interrupt signal to the running process. Intercept it by listening for the SIGINT event. To close the process, you must explicitly call process.exit().

process.ts
process.on("SIGINT", () => {
  console.log("Ctrl-C was pressed");
  process.exit();
});

See Utils for more utilities.

Was this page helpful?Suggest editsRaise issue