mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-18 18:00:35 +01:00
Exit immediately when Ctrl-C has been pressed twice
This commit is contained in:
parent
3599a30ee2
commit
2545aaabd2
1 changed files with 6 additions and 1 deletions
|
@ -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() {
|
if config.ls_colors.is_some() && config.command.is_none() {
|
||||||
let wq = Arc::clone(&wants_to_quit);
|
let wq = Arc::clone(&wants_to_quit);
|
||||||
ctrlc::set_handler(move || {
|
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();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue