avoid blocking forever in LocalPane::drop
I don't understand how fish ends up blocking forever in the related issue, but it shouldn't block us too! The price of this situation is likely a lingering zombie child process but that seems fine. refs: https://github.com/wez/wezterm/issues/558
This commit is contained in:
1 parent
5805928081
commit
d62d2a5133
1 file changed
+16
-3
+16
-3
@@ -561,12 +561,25 @@ impl LocalPane {
|
||||
}
|
||||
}
|
||||
|
||||
fn bounded_kill_wait(child: &mut Box<dyn Child + 'static>) {
|
||||
for attempt in 0..5 {
|
||||
let _ = child.kill();
|
||||
if attempt > 0 {
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
}
|
||||
|
||||
if let Ok(Some(_)) = child.try_wait() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for LocalPane {
|
||||
fn drop(&mut self) {
|
||||
// Avoid lingering zombies
|
||||
// Avoid lingering zombies if we can, but don't block forever.
|
||||
// <https://github.com/wez/wezterm/issues/558>
|
||||
if let ProcessState::Running { child, .. } = &mut *self.process.borrow_mut() {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
bounded_kill_wait(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user