summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-attach-session.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-06-03 18:28:38 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-06-03 18:28:38 +0000
commitfcff8f3164088adcd21e0148050c1e53965fd6d8 (patch)
tree8722bb7a2923dd0baa7f661965b09f26c00edcf1 /usr.bin/tmux/cmd-attach-session.c
parentee73c36c39e04c3bc247d4507dbe3a1a76211502 (diff)
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.
Diffstat (limited to 'usr.bin/tmux/cmd-attach-session.c')
-rw-r--r--usr.bin/tmux/cmd-attach-session.c29
1 files changed, 19 insertions, 10 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')));
}