diff options
author | 2019-06-03 18:28:37 +0000 | |
---|---|---|
committer | 2019-06-03 18:28:37 +0000 | |
commit | 404f99dbbdc5399abc96dc7d2ea440ad09a58245 (patch) | |
tree | c051846688134182067bc8c1ad4b502c187bf286 | |
parent | Prevent corruption of the pckbc command queue. If multiple synchronous (diff) | |
download | wireguard-openbsd-404f99dbbdc5399abc96dc7d2ea440ad09a58245.tar.xz wireguard-openbsd-404f99dbbdc5399abc96dc7d2ea440ad09a58245.zip |
Add new-session -X and attach-session -x to send SIGHUP to parent when
detaching (like detach-client -P). From Colin Watson in GitHub issue
1773.
-rw-r--r-- | usr.bin/tmux/cmd-attach-session.c | 29 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-new-session.c | 9 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 18 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 4 |
4 files changed, 40 insertions, 20 deletions
diff --git a/usr.bin/tmux/cmd-attach-session.c b/usr.bin/tmux/cmd-attach-session.c index 7950ab9f5db..75e0c16a265 100644 --- a/usr.bin/tmux/cmd-attach-session.c +++ b/usr.bin/tmux/cmd-attach-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-attach-session.c,v 1.77 2019/04/17 14:37:48 nicm Exp $ */ +/* $OpenBSD: cmd-attach-session.c,v 1.78 2019/06/03 18:28:37 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -37,8 +37,8 @@ const struct cmd_entry cmd_attach_session_entry = { .name = "attach-session", .alias = "attach", - .args = { "c:dErt:", 0, 0 }, - .usage = "[-dEr] [-c working-directory] " CMD_TARGET_SESSION_USAGE, + .args = { "c:dErt:x", 0, 0 }, + .usage = "[-dErx] [-c working-directory] " CMD_TARGET_SESSION_USAGE, /* -t is special */ @@ -48,7 +48,7 @@ const struct cmd_entry cmd_attach_session_entry = { enum cmd_retval cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag, - int rflag, const char *cflag, int Eflag) + int xflag, int rflag, const char *cflag, int Eflag) { struct cmd_find_state *current = &item->shared->current; enum cmd_find_type type; @@ -58,6 +58,7 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag, struct winlink *wl; struct window_pane *wp; char *cause; + enum msgtype msgtype; if (RB_EMPTY(&sessions)) { cmdq_error(item, "no sessions"); @@ -102,11 +103,15 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag, c->last_session = c->session; if (c->session != NULL) { - if (dflag) { + if (dflag || xflag) { + if (xflag) + msgtype = MSG_DETACHKILL; + else + msgtype = MSG_DETACH; TAILQ_FOREACH(c_loop, &clients, entry) { if (c_loop->session != s || c == c_loop) continue; - server_client_detach(c_loop, MSG_DETACH); + server_client_detach(c_loop, msgtype); } } if (!Eflag) @@ -131,11 +136,15 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag, if (rflag) c->flags |= CLIENT_READONLY; - if (dflag) { + if (dflag || xflag) { + if (xflag) + msgtype = MSG_DETACHKILL; + else + msgtype = MSG_DETACH; TAILQ_FOREACH(c_loop, &clients, entry) { if (c_loop->session != s || c == c_loop) continue; - server_client_detach(c_loop, MSG_DETACH); + server_client_detach(c_loop, msgtype); } } if (!Eflag) @@ -169,6 +178,6 @@ cmd_attach_session_exec(struct cmd *self, struct cmdq_item *item) struct args *args = self->args; return (cmd_attach_session(item, args_get(args, 't'), - args_has(args, 'd'), args_has(args, 'r'), args_get(args, 'c'), - args_has(args, 'E'))); + args_has(args, 'd'), args_has(args, 'x'), args_has(args, 'r'), + args_get(args, 'c'), args_has(args, 'E'))); } diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index b2ab646f9ea..b3fc5b00fa7 100644 --- a/usr.bin/tmux/cmd-new-session.c +++ b/usr.bin/tmux/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-session.c,v 1.119 2019/06/01 16:21:37 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.120 2019/06/03 18:28:37 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -39,8 +39,8 @@ const struct cmd_entry cmd_new_session_entry = { .name = "new-session", .alias = "new", - .args = { "Ac:dDEF:n:Ps:t:x:y:", 0, -1 }, - .usage = "[-AdDEP] [-c start-directory] [-F format] [-n window-name] " + .args = { "Ac:dDEF:n:Ps:t:x:Xy:", 0, -1 }, + .usage = "[-AdDEPX] [-c start-directory] [-F format] [-n window-name] " "[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] " "[-y height] [command]", @@ -105,7 +105,8 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) if (args_has(args, 'A')) { retval = cmd_attach_session(item, newname, args_has(args, 'D'), - 0, NULL, args_has(args, 'E')); + args_has(args, 'X'), 0, NULL, + args_has(args, 'E')); free(newname); return (retval); } diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index be62231eb8a..c1bf8e6b886 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.661 2019/05/30 07:42:41 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.662 2019/06/03 18:28:37 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 30 2019 $ +.Dd $Mdocdate: June 3 2019 $ .Dt TMUX 1 .Os .Sh NAME @@ -918,7 +918,7 @@ section. The following commands are available to manage clients and sessions: .Bl -tag -width Ds .It Xo Ic attach-session -.Op Fl dEr +.Op Fl dErx .Op Fl c Ar working-directory .Op Fl t Ar target-session .Xc @@ -931,6 +931,10 @@ If used from inside, switch the current client. If .Fl d is specified, any other clients attached to the session are detached. +If +.Fl x +is given, send SIGHUP to the parent process of the client as well as +detaching the client, typically causing it to exit. .Fl r signifies the client is read-only (only keys bound to the .Ic detach-client @@ -1048,7 +1052,7 @@ command. Lock all clients attached to .Ar target-session . .It Xo Ic new-session -.Op Fl AdDEP +.Op Fl AdDEPX .Op Fl c Ar start-directory .Op Fl F Ar format .Op Fl n Ar window-name @@ -1105,6 +1109,12 @@ already exists; in this case, behaves like .Fl d to +.Ic attach-session , +and +.Fl X +behaves like +.Fl x +to .Ic attach-session . .Pp If diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 27ad03f38e8..7fbd288869c 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.907 2019/05/28 07:18:42 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.908 2019/06/03 18:28:37 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -2009,7 +2009,7 @@ extern const struct cmd_entry *cmd_table[]; /* cmd-attach-session.c */ enum cmd_retval cmd_attach_session(struct cmdq_item *, const char *, int, int, - const char *, int); + int, const char *, int); /* cmd-parse.c */ void cmd_parse_empty(struct cmd_parse_input *); |