-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix suspend when running hx within git #1843
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,10 +31,7 @@ use crossterm::{ | |
tty::IsTty, | ||
}; | ||
#[cfg(not(windows))] | ||
use { | ||
signal_hook::{consts::signal, low_level}, | ||
signal_hook_tokio::Signals, | ||
}; | ||
use {signal_hook::consts::signal, signal_hook_tokio::Signals}; | ||
#[cfg(windows)] | ||
type Signals = futures_util::stream::Empty<()>; | ||
|
||
|
@@ -254,9 +251,19 @@ impl Application { | |
use helix_view::graphics::Rect; | ||
match signal { | ||
signal::SIGTSTP => { | ||
use nix::{ | ||
sys::signal::{self, Signal}, | ||
unistd::Pid, | ||
}; | ||
self.compositor.save_cursor(); | ||
self.restore_term().unwrap(); | ||
low_level::emulate_default_handler(signal::SIGTSTP).unwrap(); | ||
// low_level::emulate_default_handler(signal::SIGSTSP) only | ||
// send SIGSTOP to the current process but since we use | ||
// multi-process tokio, at times like using helix within | ||
// git suspend will not work since only the current process | ||
// is suspended, so we had to send SIGSTOP signal to the | ||
// whole process to make sure it is suspended correctly. | ||
signal::kill(Pid::from_raw(0), Signal::SIGSTOP).unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @archseer I can change it to |
||
} | ||
signal::SIGCONT => { | ||
self.claim_term().await.unwrap(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that you didn't follow the signal-hook docs: you're supposed to call
low_level::raise(SIGSTOP)?;
, not emulate_default_handler: https://docs.rs/signal-hook/latest/signal_hook/#a-complex-signal-handling-with-a-background-threadThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, seems to be the same underlying call though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's the same thing.