aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2021-04-06 11:09:13 +0200
committerGitHub <noreply@github.com>2021-04-06 11:09:13 +0200
commitbb87cbdd28618ce510f83f58678c2f4592cb89b2 (patch)
tree4e2b45d20949d9fe6f16f83aacb0d4b5ee4122d4 /src
parentfix(terminal): reset styles on cursor movement (#254) (diff)
downloadsl0ppij-bb87cbdd28618ce510f83f58678c2f4592cb89b2.tar.gz
sl0ppij-bb87cbdd28618ce510f83f58678c2f4592cb89b2.tar.xz
sl0ppij-bb87cbdd28618ce510f83f58678c2f4592cb89b2.zip
fix(terminal): do not hang app if terminal refuses to quit (#255)
Diffstat (limited to 'src')
-rw-r--r--src/common/command_is_executing.rs4
-rw-r--r--src/common/os_input_output.rs8
2 files changed, 9 insertions, 3 deletions
diff --git a/src/common/command_is_executing.rs b/src/common/command_is_executing.rs
index 93c44eb6..775a7bfc 100644
--- a/src/common/command_is_executing.rs
+++ b/src/common/command_is_executing.rs
@@ -23,7 +23,7 @@ impl CommandIsExecuting {
let (lock, cvar) = &*self.closing_pane;
let mut closing_pane = lock.lock().unwrap();
*closing_pane = false;
- cvar.notify_one();
+ cvar.notify_all();
}
pub fn opening_new_pane(&mut self) {
let (lock, _cvar) = &*self.opening_new_pane;
@@ -34,7 +34,7 @@ impl CommandIsExecuting {
let (lock, cvar) = &*self.opening_new_pane;
let mut opening_new_pane = lock.lock().unwrap();
*opening_new_pane = false;
- cvar.notify_one();
+ cvar.notify_all();
}
pub fn wait_until_pane_is_closed(&self) {
let (lock, cvar) = &*self.closing_pane;
diff --git a/src/common/os_input_output.rs b/src/common/os_input_output.rs
index de0c6a3b..013b9f12 100644
--- a/src/common/os_input_output.rs
+++ b/src/common/os_input_output.rs
@@ -242,7 +242,13 @@ impl OsApi for OsInputOutput {
Box::new(stdout)
}
fn kill(&mut self, pid: RawFd) -> Result<(), nix::Error> {
- kill(Pid::from_raw(pid), Some(Signal::SIGINT)).unwrap();
+ // TODO:
+ // Ideally, we should be using SIGINT rather than SIGKILL here, but there are cases in which
+ // the terminal we're trying to kill hangs on SIGINT and so all the app gets stuck
+ // that's why we're sending SIGKILL here
+ // A better solution would be to send SIGINT here and not wait for it, and then have
+ // a background thread do the waitpid stuff and send SIGKILL if the process is stuck
+ kill(Pid::from_raw(pid), Some(Signal::SIGKILL)).unwrap();
waitpid(Pid::from_raw(pid), None).unwrap();
Ok(())
}