From bf90e7b7a2ca9d5bcd30036e5a288c452fc798fe Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Thu, 25 Aug 2022 13:52:23 -0700 Subject: [PATCH] helix-term: use libc directly to send STOP signal --- Cargo.lock | 18 +++--------------- helix-term/Cargo.toml | 2 +- helix-term/src/application.rs | 19 +++++++++++-------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 27ef7212164bf..4e2fad8cb748d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -483,8 +483,8 @@ dependencies = [ "helix-view", "ignore", "indoc", + "libc", "log", - "nix", "once_cell", "pulldown-cmark", "retain_mut", @@ -629,9 +629,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.127" +version = "0.2.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "505e71a4706fa491e9b1b55f51b95d4037d0821ee40131190475f692b35b009b" +checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" [[package]] name = "libloading" @@ -708,18 +708,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "nix" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb" -dependencies = [ - "autocfg", - "bitflags", - "cfg-if", - "libc", -] - [[package]] name = "num-integer" version = "0.1.45" diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml index 0e367ca3182d7..4f5f3110fe314 100644 --- a/helix-term/Cargo.toml +++ b/helix-term/Cargo.toml @@ -71,7 +71,7 @@ grep-searcher = "0.1.10" retain_mut = "0.1.7" [target.'cfg(not(windows))'.dependencies] -nix = { version = "0.25.0", features = ["signal", "process"], default-features = false } +libc = "0.2.132" signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] } # https://github.com/vorner/signal-hook/issues/100 [build-dependencies] diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 9fdd3a18aecef..88a883fffe3de 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -385,14 +385,17 @@ impl Application { self.compositor.save_cursor(); self.restore_term().unwrap(); - // A pid of 0 sends the signal to the entire process group, allowing the user to - // regain control of their terminal if the editor was spawned under another process - // (e.g. when running `git commit`). - nix::sys::signal::kill( - nix::unistd::Pid::from_raw(0), - Some(nix::sys::signal::SIGSTOP), - ) - .unwrap(); + let res = unsafe { + // A pid of 0 sends the signal to the entire process group, allowing the user to + // regain control of their terminal if the editor was spawned under another process + // (e.g. when running `git commit`). + libc::kill(0, signal::SIGSTOP) + }; + + if res > 0 { + eprintln!("{}", std::io::Error::from_raw_os_error(res)); + std::process::exit(res); + } } signal::SIGCONT => { self.claim_term().await.unwrap();