Skip to content

Comments

fix(input): handle Ctrl+C via SIGINT signal instead of keypress#491

Merged
cyqsimon merged 4 commits intoimsnif:mainfrom
chiranjeevi-max:fix/input-sigint-handling
Feb 11, 2026
Merged

fix(input): handle Ctrl+C via SIGINT signal instead of keypress#491
cyqsimon merged 4 commits intoimsnif:mainfrom
chiranjeevi-max:fix/input-sigint-handling

Conversation

@chiranjeevi-max
Copy link
Contributor

Fixes #487

Previously, bandwhich intercepted Ctrl+C as a keyboard event, which caused it to exit even when users had disabled SIGINT via stty intr ^-.

Now uses the ctrlc crate to properly handle the SIGINT signal. The q key remains as the keyboard-based quit option.

@chiranjeevi-max chiranjeevi-max force-pushed the fix/input-sigint-handling branch from d1dea20 to 72cf7c5 Compare February 10, 2026 20:03
@chiranjeevi-max chiranjeevi-max force-pushed the fix/input-sigint-handling branch from 72cf7c5 to 5909d45 Compare February 11, 2026 04:52
@chiranjeevi-max
Copy link
Contributor Author

I noticed a hang issue when receiving a SIGINT.
=> the handler sets running = false, but the terminal_event_handler thread was blocked indefinitely on crossterm::event::read().
=> Since read() is a blocking call, the thread never got a chance to check the running flag, causing the app to hang on SIGINT.

The Fix:

  • I used poll() with 100ms timeout instead of blocking read() in TerminalEvents::next() and also change the event loop to check running flag between poll timeouts.
  • Add terminal cleanup after start() returns to restore terminal state on SIGINT exit

Copy link
Collaborator

@cyqsimon cyqsimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry about the Windows test failures. CI downloads npcap but for some reason it's unreliable. Haven't had time to check why yet.

@cyqsimon cyqsimon merged commit cbcffe8 into imsnif:main Feb 11, 2026
34 of 36 checks passed
@cyqsimon
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ctrl+C closes even without signal

2 participants