mirror of
https://github.com/uutils/coreutils
synced 2025-01-19 00:24:13 +00:00
sort: add comments to wait_if_signal function and its usage
This commit is contained in:
parent
e43872d4c7
commit
898be12a33
2 changed files with 5 additions and 1 deletions
|
@ -1268,6 +1268,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
settings.init_precomputed();
|
||||
|
||||
let result = exec(&mut files, &settings, output, &mut tmp_dir);
|
||||
// Wait here if `SIGINT` was received,
|
||||
// for signal handler to do its work and terminate the program.
|
||||
tmp_dir.wait_if_signal();
|
||||
result
|
||||
}
|
||||
|
|
|
@ -45,7 +45,8 @@ impl TmpDirWrapper {
|
|||
let path = self.temp_dir.as_ref().unwrap().path().to_owned();
|
||||
let lock = self.lock.clone();
|
||||
ctrlc::set_handler(move || {
|
||||
// Take the lock so that `next_file_path` returns no new file path.
|
||||
// Take the lock so that `next_file_path` returns no new file path,
|
||||
// and the program doesn't terminate before the handler has finished
|
||||
let _lock = lock.lock().unwrap();
|
||||
if let Err(e) = remove_tmp_dir(&path) {
|
||||
show_error!("failed to delete temporary directory: {}", e);
|
||||
|
@ -70,6 +71,7 @@ impl TmpDirWrapper {
|
|||
))
|
||||
}
|
||||
|
||||
/// Function just waits if signal handler was called
|
||||
pub fn wait_if_signal(&self) {
|
||||
let _lock = self.lock.lock().unwrap();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue