wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
16.74k stars 751 forks source link

zellij and tmux killed after exiting #4562

Closed uncomfyhalomacro closed 10 months ago

uncomfyhalomacro commented 10 months ago

What Operating System(s) are you seeing this problem on?

Linux Wayland

Which Wayland compositor or X11 Window manager(s) are you using?

RiverWM (Wlroots/Wayland)

WezTerm version

wezterm 20230712.072601.f4abf8fd+git207 (latest commit)

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

Exiting wezterm in an active zellij/tmux session kills zellij or tmux.

To Reproduce

  1. Run zellij or tmux
  2. Quits Wezterm
  3. Run zellij list or tmux list-sessions.
  4. No active sessions.

Configuration

local wezterm = require 'wezterm'

local config = {}

if wezterm.config_builder then
  config = wezterm.config_builder()
end

config.window_decorations = "RESIZE"

config.font = wezterm.font {
  family = "Monaspace Neon",
  harfbuzz_features = {
    "salt=1",
    "dlig=1",
    "zero",
  }
}

local italic_font =
{
  italic = true,
  intensity = "Normal",
  font = wezterm.font {
    family = "Monaspace Radon",
    harfbuzz_features = {
      "salt=1",
      "dlig=1",
      "zero",
    }
  }
}

local bold_italic_font =
{
  italic = true,
  intensity = "Bold",
  font = wezterm.font {
    family = "Monaspace Radon ExtraBold",
    harfbuzz_features = {
      "salt=1",
      "dlig=1",
      "zero",
    }
  }
}

local light_italic_font =
{
  italic = true,
  intensity = "Half",
  font = wezterm.font {
    family = "Monaspace Radon Light",
    harfbuzz_features = {
      "salt=1",
      "dlig=1",
      "zero",
    }
  }
}

local light_font =
{
  italic = false,
  intensity = "Half",
  font = wezterm.font {
    family = "Monaspace Xenon Light",
    harfbuzz_features = {
      "salt=1",
      "dlig=1",
      "zero",
    }
  }
}

local bold_font =
{
  italic = false,
  intensity = "Bold",
  font = wezterm.font {
    family = "Monaspace Krypton ExtraBold",
    harfbuzz_features = {
      "salt=1",
      "dlig=1",
      "zero",
    }
  }
}

config.font_rules = {
  light_font,
  bold_font,
  italic_font,
  light_italic_font,
  bold_italic_font
}

config.font_size = 14.0

config.hide_tab_bar_if_only_one_tab = true

config.term = "wezterm"

local function scheme_for_appearance(appearance)
  if appearance:find 'Dark' then
    return 'catppuccin-mocha'
  else
    return 'catppuccin-latte'
  end
end

wezterm.on('window-config-reloaded', function(window, pane)
  local overrides = window:get_config_overrides() or {}
  local appearance = window:get_appearance()
  local scheme = scheme_for_appearance(appearance)
  if overrides.color_scheme ~= scheme then
    overrides.color_scheme = scheme
    window:set_config_overrides(overrides)
  end
end)

-- if tonumber(os.date("%H")) <= 17 then
--   config.color_scheme = 'catppuccin-latte'
-- else
--   config.color_scheme = 'catppuccin-mocha'
-- end

config.skip_close_confirmation_for_processes_named = {
  'bash',
  'sh',
  'zsh',
  'fish',
  'tmux',
  'zellij',
  'nu',
  'cmd.exe',
  'pwsh.exe',
  'powershell.exe',
}

config.exit_behavior = "Close"

return config

Expected Behavior

Zellij or Tmux sessions should not be killed after exit.

Logs

No response

Anything else?

I seem to notice a strange behavior when closing wezterm. Let's say we have multiple tabs or panes for both tmux or zellij, the zellij tabs or tmux panes will quit after each

  1. attach tmux/zellij session
  2. close wezterm
  3. open wezterm. go back to 1.

That's weird because a friend of mine never experienced this

uncomfyhalomacro commented 10 months ago

Seems there might be some things i didn't notice. no logs and i cant repro it now

uncomfyhalomacro commented 10 months ago

Reopened because idk why it's still happening :/ maybe it's a compositor issue

uncomfyhalomacro commented 10 months ago

I wonder if it's because of this description

Closes the current pane. If that was the last pane in the tab, closes the tab. If that was the last tab, closes that window. If that was the last window, wezterm terminates.

The act of closing a pane shuts down the PTY associated with the pane and then kills the process associated with that pane.

uncomfyhalomacro commented 10 months ago

Patching this with

diff --git a/pty/src/unix.rs b/pty/src/unix.rs
index cbe0f76..92bf82b 100644
--- a/pty/src/unix.rs
+++ b/pty/src/unix.rs
@@ -396,9 +396,9 @@ impl Drop for UnixMasterWriter {
             // EOF is only interpreted after a newline, so if it is set,
             // we send a newline followed by EOF.
             let eot = t.c_cc[libc::VEOF];
-            if eot != 0 {
-                let _ = self.fd.0.write_all(&[b'\n', eot]);
-            }
+            // if eot != 0 {
+            //     let _ = self.fd.0.write_all(&[b'\n', eot]);
+            // }
         }
     }
 }

fixes it.

uncomfyhalomacro commented 10 months ago

Closing but this is not resolved

github-actions[bot] commented 9 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.