From 32013424c97f751ce7843930f95ac1e5c205da90 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 | 2 +- helix-term/Cargo.toml | 2 +- helix-term/src/application.rs | 19 +++++++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7c0c94ff8534c..8f9628ac91709 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1220,8 +1220,8 @@ dependencies = [ "helix-view", "ignore", "indoc", + "libc", "log", - "nix", "once_cell", "pulldown-cmark", "serde", diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml index 1de55c3d9b822..025136761e891 100644 --- a/helix-term/Cargo.toml +++ b/helix-term/Cargo.toml @@ -72,7 +72,7 @@ grep-searcher = "0.1.10" [target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100 signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] } -nix = { version = "0.25.0", features = ["signal", "process"], default-features = false } +libc = "0.2.132" [build-dependencies] helix-loader = { version = "0.6", path = "../helix-loader" } diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index fb663527811d2..70e248f6fcb79 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -445,14 +445,17 @@ impl Application { .ok(); 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();