MCPcopy Index your code
hub / github.com/continuedev/continue / enableSigintHandler

Function enableSigintHandler

extensions/cli/src/index.ts:59–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57
58// Sets up SIGINT handler that requires double Ctrl+C within 1 second to exit
59export function enableSigintHandler() {
60 // Remove all existing SIGINT listeners first
61 process.removeAllListeners("SIGINT");
62
63 process.on("SIGINT", async () => {
64 const now = Date.now();
65 const timeSinceLastCtrlC = now - lastCtrlCTime;
66
67 if (timeSinceLastCtrlC <= 1000 && lastCtrlCTime !== 0) {
68 // Second Ctrl+C within 1 second - exit
69 showExitMessage = false;
70 if (tuiUnmount) {
71 tuiUnmount();
72 }
73 await gracefulExit(0);
74 } else {
75 // First Ctrl+C or too much time elapsed - show exit message
76 lastCtrlCTime = now;
77 showExitMessage = true;
78 if (exitMessageCallback) {
79 exitMessageCallback();
80 }
81
82 // Hide message after 1 second
83 setTimeout(() => {
84 showExitMessage = false;
85 if (exitMessageCallback) {
86 exitMessageCallback();
87 }
88 }, 1000);
89 }
90 });
91}
92
93// Check if "ctrl+c to exit" message should be displayed
94export function shouldShowExitMessage(): boolean {

Callers 1

startTUIChatFunction · 0.85

Calls 2

gracefulExitFunction · 0.85
onMethod · 0.65

Tested by

no test coverage detected