mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00:00
Add two new values for the destroy-unattached option to destroy sessions
only if they are not members of sessions groups, from Mark Huang, GitHub issue 3806.
This commit is contained in:
22
server-fn.c
22
server-fn.c
@ -454,7 +454,8 @@ server_destroy_session(struct session *s)
|
||||
void
|
||||
server_check_unattached(void)
|
||||
{
|
||||
struct session *s;
|
||||
struct session *s;
|
||||
struct session_group *sg;
|
||||
|
||||
/*
|
||||
* If any sessions are no longer attached and have destroy-unattached
|
||||
@ -463,8 +464,23 @@ server_check_unattached(void)
|
||||
RB_FOREACH(s, sessions, &sessions) {
|
||||
if (s->attached != 0)
|
||||
continue;
|
||||
if (options_get_number (s->options, "destroy-unattached"))
|
||||
session_destroy(s, 1, __func__);
|
||||
switch (options_get_number(s->options, "destroy-unattached")) {
|
||||
case 0: /* off */
|
||||
continue;
|
||||
case 1: /* on */
|
||||
break;
|
||||
case 2: /* keep-last */
|
||||
sg = session_group_contains(s);
|
||||
if (sg == NULL || session_group_count(sg) <= 1)
|
||||
continue;
|
||||
break;
|
||||
case 3: /* keep-group */
|
||||
sg = session_group_contains(s);
|
||||
if (sg != NULL && session_group_count(sg) == 1)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
session_destroy(s, 1, __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user