From 6fea7318cea9a6bc80ba1b84f03a06192f5ba8c1 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 6 Jul 2022 08:31:59 +0000 Subject: [PATCH] Defer reading from control client until the command line command has completed. --- usr.bin/tmux/cmd-find.c | 4 ++-- usr.bin/tmux/control.c | 10 ++++++++-- usr.bin/tmux/server-client.c | 7 +++++-- usr.bin/tmux/tmux.h | 3 ++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/usr.bin/tmux/cmd-find.c b/usr.bin/tmux/cmd-find.c index 9311d1d6a6c..25c430e116b 100644 --- a/usr.bin/tmux/cmd-find.c +++ b/usr.bin/tmux/cmd-find.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-find.c,v 1.79 2020/05/16 16:20:59 nicm Exp $ */ +/* $OpenBSD: cmd-find.c,v 1.80 2022/07/06 08:31:59 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -1265,7 +1265,7 @@ cmd_find_current_client(struct cmdq_item *item, int quiet) found = cmd_find_best_client(s); } if (found == NULL && item != NULL && !quiet) - cmdq_error(item, "no current client"); + abort();//cmdq_error(item, "no current client"); log_debug("%s: no target, return %p", __func__, found); return (found); } diff --git a/usr.bin/tmux/control.c b/usr.bin/tmux/control.c index 5fa84a18007..d96db22d379 100644 --- a/usr.bin/tmux/control.c +++ b/usr.bin/tmux/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.47 2021/08/25 07:09:30 nicm Exp $ */ +/* $OpenBSD: control.c,v 1.48 2022/07/06 08:31:59 nicm Exp $ */ /* * Copyright (c) 2012 Nicholas Marriott @@ -776,7 +776,6 @@ control_start(struct client *c) cs->read_event = bufferevent_new(c->fd, control_read_callback, control_write_callback, control_error_callback, c); - bufferevent_enable(cs->read_event, EV_READ); if (c->flags & CLIENT_CONTROLCONTROL) cs->write_event = cs->read_event; @@ -793,6 +792,13 @@ control_start(struct client *c) } } +/* Control client ready. */ +void +control_ready(struct client *c) +{ + bufferevent_enable(c->control_state->read_event, EV_READ); +} + /* Discard all output for a client. */ void control_discard(struct client *c) diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index adb2e9056ef..046f8ecc9e7 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.395 2022/05/30 12:55:25 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.396 2022/07/06 08:31:59 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -2791,8 +2791,11 @@ 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_EXIT) + else if (~c->flags & CLIENT_EXIT) { + if (c->flags & CLIENT_CONTROL) + control_ready(c); tty_send_requests(&c->tty); + } return (CMD_RETURN_NORMAL); } diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 413fb2b80e5..27861fcd36e 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1177 2022/07/06 07:36:36 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1178 2022/07/06 08:31:59 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -3134,6 +3134,7 @@ char *parse_window_name(const char *); /* control.c */ void control_discard(struct client *); void control_start(struct client *); +void control_ready(struct client *); void control_stop(struct client *); void control_set_pane_on(struct client *, struct window_pane *); void control_set_pane_off(struct client *, struct window_pane *); -- 2.20.1