Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort: wait when SIGINT was raised for the program to finish properly #3801

Merged
merged 3 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {

settings.init_precomputed();

exec(&mut files, &settings, output, &mut tmp_dir)
let result = exec(&mut files, &settings, output, &mut tmp_dir);
tmp_dir.wait_if_signal();
niyaznigmatullin marked this conversation as resolved.
Show resolved Hide resolved
result
}

pub fn uu_app<'a>() -> Command<'a> {
Expand Down
4 changes: 4 additions & 0 deletions src/uu/sort/src/tmp_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ impl TmpDirWrapper {
path,
))
}

pub fn wait_if_signal(&self) {
let _lock = self.lock.lock().unwrap();
}
}

/// Remove the directory at `path` by deleting its child files and then itself.
Expand Down