From f50181715425264dc1f6dfad896ee9279fd49971 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 20 Oct 2025 07:28:38 +0000 Subject: [PATCH] Fix the logic of the no-detached case for detach-on-destroy option - a previous change made it so that even in the no-detached case, tmux would always re-attach to a session, even if there weren't any detached ones. From Martin Louazel in GitHub issue 4649. --- server-fn.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server-fn.c b/server-fn.c index 0aa20e29..2180d8bb 100644 --- a/server-fn.c +++ b/server-fn.c @@ -401,7 +401,7 @@ server_find_session(struct session *s, struct session *s_loop, *s_out = NULL; RB_FOREACH(s_loop, sessions, &sessions) { - if (s_loop != s && (s_out == NULL || f(s_loop, s_out))) + if (s_loop != s && f(s_loop, s_out)) s_out = s_loop; } return (s_out); @@ -410,6 +410,8 @@ server_find_session(struct session *s, static int server_newer_session(struct session *s_loop, struct session *s_out) { + if (s_out == NULL) + return (1); return (timercmp(&s_loop->activity_time, &s_out->activity_time, >)); }