From 515dfea4b79a09513d1ede5dbb8a89c3e18b8393 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 22 Oct 2015 10:48:30 +0000 Subject: [PATCH 1/4] This should not be changed. --- server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.c b/server.c index 2aed3dbb..ff38a353 100644 --- a/server.c +++ b/server.c @@ -281,7 +281,7 @@ server_send_exit(void) if (c->flags & (CLIENT_BAD|CLIENT_SUSPENDED)) server_client_lost(c); else - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(c, MSG_SHUTDOWN, NULL, 0); c->session = NULL; } From c2c2d44c72a6e693c22bb48d54b0b337a568b70b Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 22 Oct 2015 11:00:51 +0000 Subject: [PATCH 2/4] Log identify messages. --- server-client.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server-client.c b/server-client.c index 41ecc141..435e8b1a 100644 --- a/server-client.c +++ b/server-client.c @@ -1155,38 +1155,45 @@ server_client_msg_identify(struct client *c, struct imsg *imsg) fatalx("bad MSG_IDENTIFY_FLAGS size"); memcpy(&flags, data, sizeof flags); c->flags |= flags; + log_debug("client %p IDENTIFY_FLAGS %#x", c, flags); break; case MSG_IDENTIFY_TERM: if (datalen == 0 || data[datalen - 1] != '\0') fatalx("bad MSG_IDENTIFY_TERM string"); c->term = xstrdup(data); + log_debug("client %p IDENTIFY_TERM %s", c, data); break; case MSG_IDENTIFY_TTYNAME: if (datalen == 0 || data[datalen - 1] != '\0') fatalx("bad MSG_IDENTIFY_TTYNAME string"); c->ttyname = xstrdup(data); + log_debug("client %p IDENTIFY_TTYNAME %s", c, data); break; case MSG_IDENTIFY_CWD: if (datalen == 0 || data[datalen - 1] != '\0') fatalx("bad MSG_IDENTIFY_CWD string"); if ((c->cwd = open(data, O_RDONLY)) == -1) c->cwd = open("/", O_RDONLY); + log_debug("client %p IDENTIFY_CWD %s", c, data); break; case MSG_IDENTIFY_STDIN: if (datalen != 0) fatalx("bad MSG_IDENTIFY_STDIN size"); c->fd = imsg->fd; + log_debug("client %p IDENTIFY_STDIN %d", c, imsg->fd); break; case MSG_IDENTIFY_ENVIRON: if (datalen == 0 || data[datalen - 1] != '\0') fatalx("bad MSG_IDENTIFY_ENVIRON string"); if (strchr(data, '=') != NULL) environ_put(&c->environ, data); + log_debug("client %p IDENTIFY_ENVIRON %s", c, data); break; case MSG_IDENTIFY_CLIENTPID: if (datalen != sizeof c->pid) fatalx("bad MSG_IDENTIFY_CLIENTPID size"); memcpy(&c->pid, data, sizeof c->pid); + log_debug("client %p IDENTIFY_CLIENTPID %ld", c, (long)c->pid); break; default: break; From a05c27a7e1c4d43709817d6746a510f16c960b4b Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 22 Oct 2015 11:19:31 +0000 Subject: [PATCH 3/4] Unzoom before -LRUD, reported by Andy Weidenbaum. --- cmd-select-pane.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd-select-pane.c b/cmd-select-pane.c index e76587cc..7986e98c 100644 --- a/cmd-select-pane.c +++ b/cmd-select-pane.c @@ -120,14 +120,19 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq) return (CMD_RETURN_NORMAL); } - if (args_has(self->args, 'L')) + if (args_has(self->args, 'L')) { + server_unzoom_window(wp->window); wp = window_pane_find_left(wp); - else if (args_has(self->args, 'R')) + } else if (args_has(self->args, 'R')) { + server_unzoom_window(wp->window); wp = window_pane_find_right(wp); - else if (args_has(self->args, 'U')) + } else if (args_has(self->args, 'U')) { + server_unzoom_window(wp->window); wp = window_pane_find_up(wp); - else if (args_has(self->args, 'D')) + } else if (args_has(self->args, 'D')) { + server_unzoom_window(wp->window); wp = window_pane_find_down(wp); + } if (wp == NULL) return (CMD_RETURN_NORMAL); From 3ebcf25149d75977ea97e9d4f786e0508d1a0d5e Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 22 Oct 2015 11:23:00 +0000 Subject: [PATCH 4/4] If the pane is still on all_window_panes but not actually connected to window or session (which can happen if it is killed during a command sequence and something else has a reference), fall back to the best effort. Fixes "tmux killw\; detach" for Rudis Muiznieks. --- cmd-find.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/cmd-find.c b/cmd-find.c index ec883cbd..376d9041 100644 --- a/cmd-find.c +++ b/cmd-find.c @@ -255,24 +255,35 @@ cmd_find_current_session_with_client(struct cmd_find_state *fs) wp = NULL; /* Not running in a pane. We know nothing. Find the best session. */ - if (wp == NULL) { - fs->s = cmd_find_best_session(NULL, 0, fs->flags); - if (fs->s == NULL) - return (-1); - fs->wl = fs->s->curw; - fs->idx = fs->wl->idx; - fs->w = fs->wl->window; - fs->wp = fs->w->active; - return (0); - } + if (wp == NULL) + goto unknown_pane; /* We now know the window and pane. */ fs->w = wp->window; fs->wp = wp; /* Find the best session and winlink. */ - if (cmd_find_best_session_with_window(fs) != 0) + if (cmd_find_best_session_with_window(fs) != 0) { + if (wp != NULL) { + /* + * The window may have been destroyed but the pane + * still on all_window_panes due to something else + * holding a reference. + */ + goto unknown_pane; + } return (-1); + } + return (0); + +unknown_pane: + fs->s = cmd_find_best_session(NULL, 0, fs->flags); + if (fs->s == NULL) + return (-1); + fs->wl = fs->s->curw; + fs->idx = fs->wl->idx; + fs->w = fs->wl->window; + fs->wp = fs->w->active; return (0); }