mirror of
https://github.com/sharkdp/fd
synced 2024-09-04 15:53:20 +00:00
Exit immediately when Ctrl-C has been pressed twice
This commit is contained in:
parent
3599a30ee2
commit
2545aaabd2
|
@ -110,7 +110,12 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) -
|
|||
if config.ls_colors.is_some() && config.command.is_none() {
|
||||
let wq = Arc::clone(&wants_to_quit);
|
||||
ctrlc::set_handler(move || {
|
||||
wq.store(true, Ordering::Relaxed);
|
||||
if wq.load(Ordering::Relaxed) {
|
||||
// Ctrl-C has been pressed twice, exit NOW
|
||||
process::exit(ExitCode::KilledBySigint.into());
|
||||
} else {
|
||||
wq.store(true, Ordering::Relaxed);
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue