diff options
author | 2020-04-09 12:16:16 +0000 | |
---|---|---|
committer | 2020-04-09 12:16:16 +0000 | |
commit | ab7caece48523dabdbca84386419ff3850b6d95b (patch) | |
tree | e6f81258b41747b34f90f37055aa3603803cb4f6 | |
parent | find -exec +: use sysconf to find the kernel's idea of ARG_MAX (diff) | |
download | wireguard-openbsd-ab7caece48523dabdbca84386419ff3850b6d95b.tar.xz wireguard-openbsd-ab7caece48523dabdbca84386419ff3850b6d95b.zip |
Wait until the initial command sequence is done before sending a device
attributes request and other bits that prompt a reply from the terminal.
This means that stray relies are not left on the terminal if the command
has attached and then immediately detached and tmux will not be around
to receive them. Prompted by a problem report from espie@.
-rw-r--r-- | usr.bin/tmux/server-client.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 | ||||
-rw-r--r-- | usr.bin/tmux/tty.c | 24 |
3 files changed, 22 insertions, 9 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index ecf192391c2..0605445e659 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.313 2020/04/01 11:47:44 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.314 2020/04/09 12:16:16 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1898,6 +1898,8 @@ server_client_command_done(struct cmdq_item *item, __unused void *data) if (~c->flags & CLIENT_ATTACHED) c->flags |= CLIENT_EXIT; + else if (~c->flags & CLIENT_DETACHING) + tty_send_requests(&c->tty); return (CMD_RETURN_NORMAL); } diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index f484f9fcc52..3c17deef35c 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.976 2020/04/08 11:26:07 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.977 2020/04/09 12:16:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1995,6 +1995,7 @@ int tty_init(struct tty *, struct client *, int, char *); void tty_resize(struct tty *); void tty_set_size(struct tty *, u_int, u_int, u_int, u_int); void tty_start_tty(struct tty *); +void tty_send_requests(struct tty *); void tty_stop_tty(struct tty *); void tty_set_title(struct tty *, const char *); void tty_update_mode(struct tty *, int, struct screen *); diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index 6835e97cb6f..4b2be318a9c 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.346 2020/03/24 08:09:44 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.347 2020/04/09 12:16:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -340,12 +340,7 @@ tty_start_tty(struct tty *tty) tty->flags |= TTY_FOCUS; tty_puts(tty, "\033[?1004h"); } - if (~tty->flags & TTY_HAVEDA) - tty_puts(tty, "\033[c"); - if (~tty->flags & TTY_HAVEDSR) - tty_puts(tty, "\033[1337n"); - } else - tty->flags |= (TTY_HAVEDA|TTY_HAVEDSR); + } evtimer_set(&tty->start_timer, tty_start_timer_callback, tty); evtimer_add(&tty->start_timer, &tv); @@ -362,6 +357,21 @@ tty_start_tty(struct tty *tty) } void +tty_send_requests(struct tty *tty) +{ + if (~tty->flags & TTY_STARTED) + return; + + if (tty_term_flag(tty->term, TTYC_XT)) { + if (~tty->flags & TTY_HAVEDA) + tty_puts(tty, "\033[c"); + if (~tty->flags & TTY_HAVEDSR) + tty_puts(tty, "\033[1337n"); + } else + tty->flags |= (TTY_HAVEDA|TTY_HAVEDSR); +} + +void tty_stop_tty(struct tty *tty) { struct winsize ws; |