1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-27 12:23:46 +03:00

wezterm: kill processes attached to panes when detaching from mux

This commit is contained in:
Wez Furlong 2020-09-27 19:26:45 -07:00
parent b744d986af
commit 242adbbcfe
3 changed files with 18 additions and 2 deletions

View File

@ -29,6 +29,11 @@ impl Pane for LocalPane {
RefMut::map(self.terminal.borrow_mut(), |t| &mut *t)
}
fn kill(&self) {
log::debug!("killing process in pane {}", self.pane_id);
self.process.borrow_mut().kill().ok();
}
fn is_dead(&self) -> bool {
if let Ok(None) = self.process.borrow_mut().try_wait() {
false

View File

@ -225,13 +225,23 @@ impl Mux {
pub fn remove_pane(&self, pane_id: PaneId) {
debug!("removing pane {}", pane_id);
self.panes.borrow_mut().remove(&pane_id);
if let Some(pane) = self.panes.borrow_mut().remove(&pane_id) {
pane.kill();
}
self.prune_dead_windows();
}
pub fn remove_tab(&self, tab_id: TabId) {
debug!("removing tab {}", tab_id);
self.tabs.borrow_mut().remove(&tab_id);
let mut pane_ids = vec![];
if let Some(tab) = self.tabs.borrow_mut().remove(&tab_id) {
for pos in tab.iter_panes() {
pane_ids.push(pos.pane.pane_id());
}
}
for pane_id in pane_ids {
self.remove_pane(pane_id);
}
self.prune_dead_windows();
}

View File

@ -1453,6 +1453,7 @@ pub trait Pane: Downcast {
fn mouse_event(&self, event: MouseEvent) -> anyhow::Result<()>;
fn advance_bytes(&self, buf: &[u8]);
fn is_dead(&self) -> bool;
fn kill(&self) {}
fn palette(&self) -> ColorPalette;
fn domain_id(&self) -> DomainId;