Skip to content

Commit ed713d9

Browse files
Merge #1265
1265: use signal-hook instead of ctrlc r=Emilgardis a=Emilgardis Fixes #1264 Co-authored-by: Emil Gardström <[email protected]>
2 parents b7f7ace + ca3d7a2 commit ed713d9

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

.changes/1265.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"description": "replace `ctrlc` signal handler with `signal-hook`",
3+
"type": "changed"
4+
}

Cargo.lock

Lines changed: 20 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ serde_json = "1.0.91"
4242
serde_ignored = "0.1.7"
4343
shell-words = "1.1.0"
4444
const-sha1 = "0.2.0"
45-
ctrlc = { version = "3.2.4", features = ["termination"] }
45+
signal-hook = { version = "0.3.15" }
4646
directories = "4.0.1"
4747
walkdir = { version = "2.3.2", optional = true }
4848
tempfile = "3.3.0"

src/errors.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ unsafe fn termination_handler() {
111111

112112
pub fn install_termination_hook() -> Result<()> {
113113
// SAFETY: safe since single-threaded execution.
114-
ctrlc::set_handler(|| unsafe { termination_handler() }).map_err(Into::into)
114+
unsafe {
115+
signal_hook::low_level::register(signal_hook::consts::SIGINT, || termination_handler())
116+
}
117+
.map_err(Into::into)
118+
.map(|_| ())
115119
}
116120

117121
#[derive(Debug, thiserror::Error)]

0 commit comments

Comments
 (0)