Skip to main content

Listen for CTRL+C

还没翻译译自英文(bun.com)本页 3 段都还没译

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.on("SIGINT", () => {
  console.log("Ctrl-C was pressed");
  process.exit();
});

See Utils for more utilities.

Traducción © 2026 fanyi.dev · Original © 2026 the Bun project (LICENSE.md names no copyright holder) (MIT)