From 5e78d20c709cb1ab8d44ca7a8702cc26d779227c Mon Sep 17 00:00:00 2001 From: "Andrew Borg (Kashin)" <1192958+aborg-dev@users.noreply.github.com> Date: Thu, 16 Jan 2025 15:04:21 +0000 Subject: Add option to drain PTY on shutdown This patch removes the `hold` option on `alacritty_terminal` in favor of a `drain_on_exit` option, which will drain the PTY before shutdown. The hold logic is instead handled in `alacritty`. --- alacritty_terminal/src/event_loop.rs | 13 +++++-------- alacritty_terminal/src/tty/mod.rs | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'alacritty_terminal/src') diff --git a/alacritty_terminal/src/event_loop.rs b/alacritty_terminal/src/event_loop.rs index 2b78f853..1bef1d4f 100644 --- a/alacritty_terminal/src/event_loop.rs +++ b/alacritty_terminal/src/event_loop.rs @@ -50,7 +50,7 @@ pub struct EventLoop { tx: Sender, terminal: Arc>>, event_proxy: U, - hold: bool, + drain_on_exit: bool, ref_test: bool, } @@ -64,7 +64,7 @@ where terminal: Arc>>, event_proxy: U, pty: T, - hold: bool, + drain_on_exit: bool, ref_test: bool, ) -> io::Result> { let (tx, rx) = mpsc::channel(); @@ -76,7 +76,7 @@ where rx: PeekableReceiver::new(rx), terminal, event_proxy, - hold, + drain_on_exit, ref_test, }) } @@ -261,13 +261,10 @@ where if let Some(code) = code { self.event_proxy.send_event(Event::ChildExit(code)); } - if self.hold { - // With hold enabled, make sure the PTY is drained. + if self.drain_on_exit { let _ = self.pty_read(&mut state, &mut buf, pipe.as_mut()); - } else { - // Without hold, shutdown the terminal. - self.terminal.lock().exit(); } + self.terminal.lock().exit(); self.event_proxy.send_event(Event::Wakeup); break 'event_loop; } diff --git a/alacritty_terminal/src/tty/mod.rs b/alacritty_terminal/src/tty/mod.rs index eed2a76d..208547ba 100644 --- a/alacritty_terminal/src/tty/mod.rs +++ b/alacritty_terminal/src/tty/mod.rs @@ -28,8 +28,8 @@ pub struct Options { /// Shell startup directory. pub working_directory: Option, - /// Remain open after child process exits. - pub hold: bool, + /// Drain the child process output before exiting the terminal. + pub drain_on_exit: bool, /// Extra environment variables. pub env: HashMap, -- cgit