Add -g flag to kill-session to kill all sessions in a group, GitHub

issue 5157 from github at jiku dot jp.
This commit is contained in:
nicm
2026-06-07 13:51:42 +00:00
parent 0256ee77c2
commit 343ee5ece1
2 changed files with 14 additions and 3 deletions

View File

@@ -33,8 +33,8 @@ const struct cmd_entry cmd_kill_session_entry = {
.name = "kill-session",
.alias = NULL,
.args = { "aCt:", 0, 0, NULL },
.usage = "[-aC] " CMD_TARGET_SESSION_USAGE,
.args = { "aCgt:", 0, 0, NULL },
.usage = "[-aCg] " CMD_TARGET_SESSION_USAGE,
.target = { 't', CMD_FIND_SESSION, 0 },
@@ -48,6 +48,7 @@ cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = cmd_get_args(self);
struct cmd_find_state *target = cmdq_get_target(item);
struct session *s = target->s, *sloop, *stmp;
struct session_group *sg;
struct winlink *wl;
if (args_has(args, 'C')) {
@@ -63,6 +64,12 @@ cmd_kill_session_exec(struct cmd *self, struct cmdq_item *item)
session_destroy(sloop, 1, __func__);
}
}
} else if (args_has(args, 'g') &&
(sg = session_group_contains(s)) != NULL) {
TAILQ_FOREACH_SAFE(sloop, &sg->sessions, gentry, stmp) {
server_destroy_session(sloop);
session_destroy(sloop, 1, __func__);
}
} else {
server_destroy_session(s);
session_destroy(s, 1, __func__);