From e314d847116d0de9a502e2e79e9b06f360a4f660 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 11 Jan 2022 22:35:31 -0700 Subject: [PATCH] wezterm connect unix could exit on startup This is a similar race condition to one we had before with the multiplexer, where the connection UI made us think that we didn't need to start a new process. Additionally, the attach method would unconditionally create a new client without checking whether we already had one. --- wezterm-client/src/domain.rs | 5 +++++ wezterm-gui/src/main.rs | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/wezterm-client/src/domain.rs b/wezterm-client/src/domain.rs index 47b96c781..4afc5ffcb 100644 --- a/wezterm-client/src/domain.rs +++ b/wezterm-client/src/domain.rs @@ -474,6 +474,11 @@ impl Domain for ClientDomain { } async fn attach(&self) -> anyhow::Result<()> { + if self.state() == DomainState::Attached { + // Already attached + return Ok(()); + } + let domain_id = self.local_domain_id; let config = self.config.clone(); diff --git a/wezterm-gui/src/main.rs b/wezterm-gui/src/main.rs index 98b31c960..a2a4ad7f7 100644 --- a/wezterm-gui/src/main.rs +++ b/wezterm-gui/src/main.rs @@ -267,9 +267,6 @@ async fn spawn_tab_in_default_domain_if_mux_is_empty( ) -> anyhow::Result<()> { let mux = Mux::get().unwrap(); - if !mux.is_empty() { - return Ok(()); - } let domain = mux.default_domain(); domain.attach().await?;