Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam
2026-06-09 10:30:06 +01:00
5 changed files with 62 additions and 3 deletions

View File

@@ -38,7 +38,7 @@ const struct cmd_entry cmd_new_pane_entry = {
.name = "new-pane",
.alias = "newp",
.args = { "bc:de:EfF:hIkl:Lm:p:PR:s:S:t:T:vx:X:y:Y:Z", 0, -1, NULL },
.args = { "bBc:de:EfF:hIkl:Lm:p:PR:s:S:t:T:vx:X:y:Y:Z", 0, -1, NULL },
.usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] "
"[-F format] [-l size] [-m message] [-p percentage] "
"[-s style] [-S active-border-style] "
@@ -56,7 +56,7 @@ const struct cmd_entry cmd_split_window_entry = {
.name = "split-window",
.alias = "splitw",
.args = { "bc:de:EfF:hIkl:m:p:PR:s:S:t:T:vZ", 0, -1, NULL },
.args = { "bBc:de:EfF:hIkl:m:p:PR:s:S:t:T:vZ", 0, -1, NULL },
.usage = "[-bdefhIklPvZ] [-c start-directory] [-e environment] "
"[-F format] [-l size] [-m message] [-p percentage] "
"[-s style] [-S active-border-style] "
@@ -244,5 +244,15 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
environ_free(sc.environ);
if (input)
return (CMD_RETURN_WAIT);
if (args_has(args, 'B')) {
/*
* With -B, block this command queue item until the pane's
* command exits; window_pane_block_finish will be called to
* continue it.
*/
new_wp->block_item = item;
return (CMD_RETURN_WAIT);
}
return (CMD_RETURN_NORMAL);
}

View File

@@ -497,6 +497,8 @@ server_child_exited(pid_t pid, int status)
log_debug("%%%u exited", wp->id);
wp->flags |= PANE_EXITED;
window_pane_block_finish(wp);
if (window_pane_destroy_ready(wp))
server_destroy_pane(wp, 1);
break;

13
tmux.1
View File

@@ -3382,7 +3382,7 @@ but a different format may be specified with
.Fl F .
.Tg newp
.It Xo Ic new\-pane
.Op Fl bdefhIkPvZ
.Op Fl bBdefhIkPvZ
.Op Fl c Ar start\-directory
.Op Fl e Ar environment
.Op Fl F Ar format
@@ -3458,6 +3458,17 @@ but also sets the
option for this pane to
.Ar message .
.Pp
.Fl B
blocks until
.Ar shell\-command
exits, then returns its exit status.
For example:
.Bd -literal -offset indent
$ tmux new-pane -B 'vi afile'
$ echo $?
0
.Ed
.Pp
.Fl E ,
or an empty
.Ar shell\-command ,

2
tmux.h
View File

@@ -1296,6 +1296,7 @@ struct window_pane {
char tty[TTY_NAME_MAX];
int status;
struct timeval dead_time;
struct cmdq_item *block_item; /* new-pane -B: waiting for pane exit */
int fd;
struct bufferevent *event;
@@ -3425,6 +3426,7 @@ struct window *window_find_by_id(u_int);
void window_update_activity(struct window *);
struct window *window_create(u_int, u_int, u_int, u_int);
void window_pane_set_event(struct window_pane *);
void window_pane_block_finish(struct window_pane *);
struct window_pane *window_get_active_at(struct window *, u_int, u_int);
struct window_pane *window_find_string(struct window *, const char *);
int window_has_floating_panes(struct window *);

View File

@@ -18,6 +18,7 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <ctype.h>
#include <errno.h>
@@ -380,6 +381,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);
}
@@ -1084,12 +1092,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);