summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2021-08-12 15:13:57 -0700
committerGitHub <noreply@github.com>2021-08-12 15:13:57 -0700
commit223b2c6f3d2155137451d50dc370aa624ef6ae96 (patch)
tree0fe30a9fcee4118bf9aca9343249c52175a3acf5
parent362f75e5fbcb661ee43ee1334b06f3c8d42c4c34 (diff)
Ignore ctrl-c (SIGINT) to avoid leaving an orphaned pager process. (#686)
Fixes #681
-rw-r--r--Cargo.lock37
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs4
3 files changed, 40 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index e9a98f15..1497bae8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -189,6 +189,16 @@ dependencies = [
]
[[package]]
+name = "ctrlc"
+version = "3.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "377c9b002a72a0b2c1a18c62e2f3864bdfea4a015e3683a96e24aa45dd6c02d1"
+dependencies = [
+ "nix",
+ "winapi",
+]
+
+[[package]]
name = "dirs-next"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -280,6 +290,7 @@ dependencies = [
"box_drawing",
"bytelines",
"console",
+ "ctrlc",
"dirs-next",
"error-chain",
"git2",
@@ -426,9 +437,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
-version = "0.2.81"
+version = "0.2.99"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"
+checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765"
[[package]]
name = "libgit2-sys"
@@ -491,6 +502,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
[[package]]
+name = "memoffset"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
name = "miniz_oxide"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -501,6 +521,19 @@ dependencies = [
]
[[package]]
+name = "nix"
+version = "0.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf1e25ee6b412c2a1e3fcb6a4499a5c1bfe7f43e014bdce9a6b6666e5aa2d187"
+dependencies = [
+ "bitflags",
+ "cc",
+ "cfg-if 1.0.0",
+ "libc",
+ "memoffset",
+]
+
+[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index a8956c10..83f7b465 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,6 +22,7 @@ bitflags = "1.3.1"
box_drawing = "0.1.2"
bytelines = "2.2.2"
console = "0.14.1"
+ctrlc = "3.2.0"
dirs-next = "2.0.0"
grep-cli = "0.1.6"
itertools = "0.10.1"
diff --git a/src/main.rs b/src/main.rs
index fc649f18..a36ee795 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -109,6 +109,10 @@ fn run_app() -> std::io::Result<i32> {
#[cfg(not(tarpaulin_include))]
fn main() -> std::io::Result<()> {
+ // Ignore ctrl-c (SIGINT) to avoid leaving an orphaned pager process.
+ // See https://github.com/dandavison/delta/issues/681
+ ctrlc::set_handler(|| {})
+ .unwrap_or_else(|err| eprintln!("Failed to set ctrl-c handler: {}", err));
let exit_code = run_app()?;
// when you call process::exit, no destructors are called, so we want to do it only once, here
process::exit(exit_code);