Tmux client discards stdin when starting
romkatv opened this issue · comments
When tmux client starts, it discards all buffered input.
- Run:
sh -c 'sleep 5; tmux'
- Quickly type
echo hello
and hit ENTER. - Wait for tmux to start login shell.
- Observe that neither the
echo hello
command nor its output appear on the screen. This is unexpected. The expected behavior is the same as if step (2) was performed after step (3).
Other programs don't discard buffered input. For example, try replacing tmux
in the command given above with head -1
, sh
, or screen -q
.
I've reproduced this on Linux x86_64 (Ubuntu 20.04) with tmux 3.2a and bf595a0 (the tip of master
at the time of this writing). I don't have .tmux.conf
. My TERM
is xterm-256color. Logs from tmux: tmux-logs.tar.gz.
The logs were captured in the following environment:
docker run -e TERM -e LC_ALL=C.UTF-8 -it --rm ubuntu:focal bash -xuec '
cd
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get upgrade -y
apt-get install -y git libevent-dev ncurses-dev build-essential bison pkg-config autogen autoconf screen
git clone https://github.com/tmux/tmux.git
cd tmux
sh ./autogen.sh
./configure --prefix /tmp/tmux --exec-prefix /tmp/tmux
make install
cd
exec bash'
The actual command I ran to generate logs:
sh -c 'sleep 5; /tmp/tmux/bin/tmux -vv'
I typed echo hello
and hit ENTER while sleep 5
was running. When bash
prompt showed up, I pressed Ctrl-D.
Try this please:
--- tty.c 17 Aug 2021 11:20:13 -0000 1.403
+++ tty.c 1 Oct 2021 15:34:14 -0000
@@ -314,7 +314,7 @@ tty_start_tty(struct tty *tty)
tio.c_cc[VMIN] = 1;
tio.c_cc[VTIME] = 0;
if (tcsetattr(c->fd, TCSANOW, &tio) == 0)
- tcflush(c->fd, TCIOFLUSH);
+ tcflush(c->fd, TCOFLUSH);
tty_putcode(tty, TTYC_SMCUP);
That was fast!
The patch works 👍
I have applied this to OpenBSD now (accidentally as part of another commit, but it was next anyway :-). It'll be in GitHub later. Thanks!
I see that it has been merged here: 9b1fdb2#diff-2dec3ca953f8622e2bc9fe13a2eb464d057905e6f9313682665328c6b67910e6
Cheers!
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.