From cb44afd41522ce058b71d76e9deb433d7d0a694c Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 8 Oct 2026 07:06:26 +0000 Subject: [PATCH] Fix bugs with empty panes and load-buffer -w, GitHub issue 5701 from Alexandre Fiori. --- cmd-load-buffer.c | 6 +++--- spawn.c | 4 +++- window.c | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd-load-buffer.c b/cmd-load-buffer.c index df35b82c1..e9b016071 100644 --- a/cmd-load-buffer.c +++ b/cmd-load-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-load-buffer.c,v 1.66 2025/10/28 07:32:26 nicm Exp $ */ +/* $OpenBSD: cmd-load-buffer.c,v 1.67 2026/10/08 07:06:26 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha @@ -78,9 +78,9 @@ cmd_load_buffer_done(__unused struct client *c, const char *path, int error, tc->session != NULL && (~tc->flags & CLIENT_DEAD)) tty_set_selection(&tc->tty, "", copy, bsize); - if (tc != NULL) - server_client_unref(tc); } + if (tc != NULL) + server_client_unref(tc); cmdq_continue(item); free(cdata->name); diff --git a/spawn.c b/spawn.c index b0d3aedee..2a0c73a41 100644 --- a/spawn.c +++ b/spawn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spawn.c,v 1.55 2026/10/07 12:55:41 nicm Exp $ */ +/* $OpenBSD: spawn.c,v 1.56 2026/10/08 07:06:26 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott @@ -462,6 +462,8 @@ spawn_pane(struct spawn_context *sc, char **cause) /* If the command is empty, don't fork a child process. */ if (sc->flags & SPAWN_EMPTY) { new_wp->flags |= PANE_EMPTY; + new_wp->pid = 0; + *new_wp->tty = '\0'; new_wp->base.mode &= ~MODE_CURSOR; new_wp->base.mode |= MODE_CRLF; goto complete; diff --git a/window.c b/window.c index 662871313..0b280f19a 100644 --- a/window.c +++ b/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.384 2026/10/02 12:48:52 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.385 2026/10/08 07:06:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1585,9 +1585,11 @@ window_pane_destroy(struct window_pane *wp) window_pane_free_modes(wp); screen_write_sync_clear_dirty(wp); - if (wp->fd != -1) { + if (wp->event != NULL) { bufferevent_free(wp->event); wp->event = NULL; + } + if (wp->fd != -1) { close(wp->fd); wp->fd = -1; }