mirror of
https://github.com/tmux/tmux.git
synced 2026-10-06 17:49:52 +00:00
Do not do anything in session_detach and rely on the caller destroying
the session, otherwise grouped sessions can reuse a session with no windows. From Jeong, Heon in GitHub issue 5620.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: server-fn.c,v 1.153 2026/09/10 11:02:18 nicm Exp $ */
|
/* $OpenBSD: server-fn.c,v 1.154 2026/09/21 12:43:36 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
@@ -310,8 +310,8 @@ server_link_window(struct session *src, struct winlink *srcwl,
|
|||||||
}
|
}
|
||||||
if (killflag) {
|
if (killflag) {
|
||||||
/*
|
/*
|
||||||
* Can't use session_detach as it will destroy session
|
* Can't use session_detach as it won't detach the only
|
||||||
* if this makes it empty.
|
* window.
|
||||||
*/
|
*/
|
||||||
events_fire_winlink("window-unlinked", dstwl);
|
events_fire_winlink("window-unlinked", dstwl);
|
||||||
dstwl->flags &= ~WINLINK_ALERTFLAGS;
|
dstwl->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
|
|||||||
13
session.c
13
session.c
@@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: session.c,v 1.107 2026/08/05 07:35:35 nicm Exp $ */
|
/* $OpenBSD: session.c,v 1.108 2026/09/21 12:43:36 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
@@ -336,10 +336,17 @@ session_attach(struct session *s, struct window *w, int idx, char **cause)
|
|||||||
return (wl);
|
return (wl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Detach a window from a session. */
|
/*
|
||||||
|
* Detach a window from a session. Returns 1 if the window has not been
|
||||||
|
* detached - the caller must destroy the session.
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
session_detach(struct session *s, struct winlink *wl)
|
session_detach(struct session *s, struct winlink *wl)
|
||||||
{
|
{
|
||||||
|
if (RB_MIN(winlinks, &s->windows) == wl &&
|
||||||
|
RB_MAX(winlinks, &s->windows) == wl)
|
||||||
|
return (1);
|
||||||
|
|
||||||
if (s->curw == wl &&
|
if (s->curw == wl &&
|
||||||
session_last(s) != 0 &&
|
session_last(s) != 0 &&
|
||||||
session_previous(s, 0) != 0)
|
session_previous(s, 0) != 0)
|
||||||
@@ -352,8 +359,6 @@ session_detach(struct session *s, struct winlink *wl)
|
|||||||
|
|
||||||
session_group_synchronize_from(s);
|
session_group_synchronize_from(s);
|
||||||
|
|
||||||
if (RB_EMPTY(&s->windows))
|
|
||||||
return (1);
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
spawn.c
6
spawn.c
@@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: spawn.c,v 1.52 2026/08/20 09:19:24 nicm Exp $ */
|
/* $OpenBSD: spawn.c,v 1.53 2026/09/21 12:43:36 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
|
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
@@ -166,8 +166,8 @@ spawn_window(struct spawn_context *sc, char **cause)
|
|||||||
}
|
}
|
||||||
if (wl != NULL) {
|
if (wl != NULL) {
|
||||||
/*
|
/*
|
||||||
* Can't use session_detach as it will destroy session
|
* Can't use session_detach as it won't detach the only
|
||||||
* if this makes it empty.
|
* window.
|
||||||
*/
|
*/
|
||||||
wl->flags &= ~WINLINK_ALERTFLAGS;
|
wl->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
events_fire_winlink("window-unlinked", wl);
|
events_fire_winlink("window-unlinked", wl);
|
||||||
|
|||||||
Reference in New Issue
Block a user