Skip to content

Instantly share code, notes, and snippets.

@fzn0x
Created April 20, 2024 22:21
Show Gist options
  • Save fzn0x/97e050d4e84293a368e66a4034e1977f to your computer and use it in GitHub Desktop.
Save fzn0x/97e050d4e84293a368e66a4034e1977f to your computer and use it in GitHub Desktop.
Temporary solution for https://github.com/oven-sh/bun/issues/10403 Cannot exit all the processes when CTRL + C in readline, need to enter twice, or enter after CTRL + C.
import * as readline from "node:readline";
// TODO: remove code when https://github.com/oven-sh/bun/issues/10403 is fixed
if (process.stdin.isTTY) {
readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
process.stdin.on("keypress", (str, key) => {
if (key.ctrl && key.name === "c") process.exit();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment