File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ chrono = "0.4"
3131clap-verbosity-flag = " 3.0.3"
3232clap = { version = " 4.5.41" , features = [" derive" ] }
3333crossterm = " 0.29.0"
34+ ctrlc = " 3.4"
3435derive_more = { version = " 2.0.1" , features = [" debug" ] }
3536eyre = " 0.6.12"
3637itertools = " 0.14.0"
Original file line number Diff line number Diff line change 9696 let cumulative_time = Arc :: new ( RwLock :: new ( Duration :: new ( 0 , 0 ) ) ) ;
9797 let table_cycle_offset = Arc :: new ( AtomicUsize :: new ( 0 ) ) ;
9898
99+ // handle SIGINT properly instead of as a keypress
100+ // see https://github.com/imsnif/bandwhich/issues/487
101+ {
102+ let running = running. clone ( ) ;
103+ ctrlc:: set_handler ( move || {
104+ running. store ( false , Ordering :: Release ) ;
105+ } )
106+ . expect ( "failed to set SIGINT handler" ) ;
107+ }
108+
99109 let mut active_threads = vec ! [ ] ;
100110
101111 let terminal_events = os_input. terminal_events ;
@@ -192,12 +202,6 @@ where
192202 ) ;
193203 }
194204 Event :: Key ( KeyEvent {
195- modifiers : KeyModifiers :: CONTROL ,
196- code : KeyCode :: Char ( 'c' ) ,
197- kind : KeyEventKind :: Press ,
198- ..
199- } )
200- | Event :: Key ( KeyEvent {
201205 modifiers : KeyModifiers :: NONE ,
202206 code : KeyCode :: Char ( 'q' ) ,
203207 kind : KeyEventKind :: Press ,
Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ use crate::{
2525pub fn sleep_and_quit_events ( sleep_num : usize ) -> Box < TerminalEvents > {
2626 let events = iter:: repeat_n ( None , sleep_num)
2727 . chain ( [ Some ( Event :: Key ( KeyEvent :: new (
28- KeyCode :: Char ( 'c ' ) ,
29- KeyModifiers :: CONTROL ,
28+ KeyCode :: Char ( 'q ' ) ,
29+ KeyModifiers :: NONE ,
3030 ) ) ) ] )
3131 . collect ( ) ;
3232 Box :: new ( TerminalEvents :: new ( events) )
@@ -37,8 +37,8 @@ pub fn sleep_resize_and_quit_events(sleep_num: usize) -> Box<TerminalEvents> {
3737 . chain ( [
3838 Some ( Event :: Resize ( 100 , 100 ) ) ,
3939 Some ( Event :: Key ( KeyEvent :: new (
40- KeyCode :: Char ( 'c ' ) ,
41- KeyModifiers :: CONTROL ,
40+ KeyCode :: Char ( 'q ' ) ,
41+ KeyModifiers :: NONE ,
4242 ) ) ) ,
4343 ] )
4444 . collect ( ) ;
You can’t perform that action at this time.
0 commit comments