Skip to content
Myr

Raise SIGINT when dying by ^C

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes #854.

authored by Tavian Barnes · committed by David Peter · parent 2b1bf47 · Browse files · 3 files+15 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+15 added−0 removed

  • other:+15 added−0 removed

3 files+15 added−0 removed

modified:src/exit_codes.rs+13 added
1use std::process;23#[cfg(unix)]4use nix::sys::signal::{raise, signal, SigHandler, Signal};56#[derive(Debug, Clone, Copy, PartialEq)]7pub enum ExitCode {8 Success,9 HasResults(bool),
18 unmodified lines
28 }2930 /// Exit the process with the appropriate code.31 pub fn exit(self) -> ! {32 #[cfg(unix)]33 if self == ExitCode::KilledBySigint {34 // Get rid of the SIGINT handler, if present, and raise SIGINT35 unsafe {36 if signal(Signal::SIGINT, SigHandler::SigDfl).is_ok() {37 let _ = raise(Signal::SIGINT);38 }39 }40 }4142 process::exit(self.into())43 }44}45
49 unmodified lines
modified:Cargo.lock+1 added
173 unmodified lines
174 "jemallocator",175 "lazy_static",176 "libc",177 "lscolors",178 "nix",179 "normpath",180 "num_cpus",181 "once_cell",182 "regex",
486 unmodified lines
modified:Cargo.toml+1 added