Add -B to new-pane/split-window to block until the command exits, like

run-shell -b.
This commit is contained in:
nicm
2026-06-09 09:11:05 +00:00
parent 27c58c764d
commit d5c9196348
5 changed files with 62 additions and 3 deletions

View File

@@ -18,6 +18,7 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <ctype.h>
#include <errno.h>
@@ -382,6 +383,13 @@ window_pane_destroy_ready(struct window_pane *wp)
if (~wp->flags & PANE_EXITED)
return (0);
/*
* If a command queue item is blocked on this pane, wait for the
* child's exit status before destroying it.
*/
if (wp->block_item != NULL && (~wp->flags & PANE_STATUSREADY))
return (0);
return (1);
}
@@ -1077,12 +1085,38 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
return (wp);
}
void
window_pane_block_finish(struct window_pane *wp)
{
struct cmdq_item *item = wp->block_item;
struct client *c;
int retval = 0;
if (item == NULL)
return;
wp->block_item = NULL;
if (wp->flags & PANE_STATUSREADY) {
if (WIFEXITED(wp->status))
retval = WEXITSTATUS(wp->status);
else if (WIFSIGNALED(wp->status))
retval = WTERMSIG(wp->status) + 128;
}
c = cmdq_get_client(item);
if (c != NULL && c->session == NULL)
c->retval = retval;
cmdq_continue(item);
}
static void
window_pane_destroy(struct window_pane *wp)
{
struct window_pane_resize *r;
struct window_pane_resize *r1;
window_pane_block_finish(wp);
window_pane_reset_mode_all(wp);
free(wp->searchstr);