Skip to content

Commit

Permalink
helix-term: use libc directly to send STOP signal
Browse files Browse the repository at this point in the history
  • Loading branch information
cole-h committed Aug 25, 2022
1 parent 091b0bd commit bf90e7b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
18 changes: 3 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion helix-term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
19 changes: 11 additions & 8 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit bf90e7b

Please sign in to comment.