-
-
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
Conversation
When editing git commit message using helix, when ctrl-z is pressed the terminal will get stuck since helix does not suspend correctly, as helix is currently using tokio with multi-threads, with signal-hook default low_level::emulate_default_handler it only send the SIGSTOP to the current process but tokio uses multi-process so not everything gets suspended and the terminal also gets stuck. Now switched to use libc kill function and send it to pid 0 so that all processes gets suspended correctly.
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
@archseer I can change it to libc::kill
if you want since nix is an extra new crate now (libc we already need it anyway) but we only use this one line, but using libc directly will need unsafe and might take up several lines.
use nix::{ | ||
sys::signal::{self, Signal}, | ||
unistd::Pid, | ||
}; | ||
self.compositor.save_cursor(); | ||
self.restore_term().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-thread
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.
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.
Should fix this within signal-hook |
When editing git commit message using helix, when ctrl-z is pressed
the terminal will get stuck since helix does not suspend correctly,
as helix is currently using tokio with multi-threads, with signal-hook
default low_level::emulate_default_handler it only send the SIGSTOP to
the current process but tokio uses multi-process so not everything gets
suspended and the terminal also gets stuck.
Now switched to use libc kill function and send it to pid 0 so that all
processes gets suspended correctly.
Maybe I need to create an issue in signal-hook for this to check why they didn't kill all processes.