fix(terminal): do not hang app if terminal refuses to quit (#255)
This commit is contained in:
parent
f84d293c1b
commit
bb87cbdd28
2 changed files with 9 additions and 3 deletions
|
|
@ -23,7 +23,7 @@ impl CommandIsExecuting {
|
||||||
let (lock, cvar) = &*self.closing_pane;
|
let (lock, cvar) = &*self.closing_pane;
|
||||||
let mut closing_pane = lock.lock().unwrap();
|
let mut closing_pane = lock.lock().unwrap();
|
||||||
*closing_pane = false;
|
*closing_pane = false;
|
||||||
cvar.notify_one();
|
cvar.notify_all();
|
||||||
}
|
}
|
||||||
pub fn opening_new_pane(&mut self) {
|
pub fn opening_new_pane(&mut self) {
|
||||||
let (lock, _cvar) = &*self.opening_new_pane;
|
let (lock, _cvar) = &*self.opening_new_pane;
|
||||||
|
|
@ -34,7 +34,7 @@ impl CommandIsExecuting {
|
||||||
let (lock, cvar) = &*self.opening_new_pane;
|
let (lock, cvar) = &*self.opening_new_pane;
|
||||||
let mut opening_new_pane = lock.lock().unwrap();
|
let mut opening_new_pane = lock.lock().unwrap();
|
||||||
*opening_new_pane = false;
|
*opening_new_pane = false;
|
||||||
cvar.notify_one();
|
cvar.notify_all();
|
||||||
}
|
}
|
||||||
pub fn wait_until_pane_is_closed(&self) {
|
pub fn wait_until_pane_is_closed(&self) {
|
||||||
let (lock, cvar) = &*self.closing_pane;
|
let (lock, cvar) = &*self.closing_pane;
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,13 @@ impl OsApi for OsInputOutput {
|
||||||
Box::new(stdout)
|
Box::new(stdout)
|
||||||
}
|
}
|
||||||
fn kill(&mut self, pid: RawFd) -> Result<(), nix::Error> {
|
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();
|
waitpid(Pid::from_raw(pid), None).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue