aboutsummaryrefslogtreecommitdiff
path: root/spawn.c
diff options
context:
space:
mode:
authornicm <nicm>2019-05-03 20:44:24 +0000
committernicm <nicm>2019-05-03 20:44:24 +0000
commit9f75635596d0a01282156eb9e17fde6f4205c05c (patch)
treec2992361a46c5ed7a17c2f273d3e8aba5bc16480 /spawn.c
parente8e4f4ec3e4de0bd0e4eb2a7ee995fb6f5f7f937 (diff)
downloadrtmux-9f75635596d0a01282156eb9e17fde6f4205c05c.tar.gz
rtmux-9f75635596d0a01282156eb9e17fde6f4205c05c.tar.bz2
rtmux-9f75635596d0a01282156eb9e17fde6f4205c05c.zip
Allow panes to be empty (no command), output can be piped to them with
split-window or display-message -I.
Diffstat (limited to 'spawn.c')
-rw-r--r--spawn.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/spawn.c b/spawn.c
index 8e577ff5..84f468e2 100644
--- a/spawn.c
+++ b/spawn.c
@@ -332,6 +332,14 @@ spawn_pane(struct spawn_context *sc, char **cause)
cmd_log_argv(new_wp->argc, new_wp->argv, __func__);
environ_log(child, "%s: environment ", __func__);
+ /* If the command is empty, don't fork a child process. */
+ if (sc->flags & SPAWN_EMPTY) {
+ new_wp->flags |= PANE_EMPTY;
+ new_wp->base.mode &= ~MODE_CURSOR;
+ new_wp->base.mode |= MODE_CRLF;
+ goto complete;
+ }
+
/* Initialize the window size. */
memset(&ws, 0, sizeof ws);
ws.ws_col = screen_size_x(&new_wp->base);
@@ -355,25 +363,8 @@ spawn_pane(struct spawn_context *sc, char **cause)
}
/* In the parent process, everything is done now. */
- if (new_wp->pid != 0) {
- new_wp->pipe_off = 0;
- new_wp->flags &= ~PANE_EXITED;
-
- sigprocmask(SIG_SETMASK, &oldset, NULL);
- window_pane_set_event(new_wp);
-
- if (sc->flags & SPAWN_RESPAWN)
- return (new_wp);
- if ((~sc->flags & SPAWN_DETACHED) || w->active == NULL) {
- if (sc->flags & SPAWN_NONOTIFY)
- window_set_active_pane(w, new_wp, 0);
- else
- window_set_active_pane(w, new_wp, 1);
- }
- if (~sc->flags & SPAWN_NONOTIFY)
- notify_window("window-layout-changed", w);
- return (new_wp);
- }
+ if (new_wp->pid != 0)
+ goto complete;
/*
* Child process. Change to the working directory or home if that
@@ -433,4 +424,23 @@ spawn_pane(struct spawn_context *sc, char **cause)
xasprintf(&argv0, "-%s", new_wp->shell);
execl(new_wp->shell, argv0, (char *)NULL);
_exit(1);
+
+complete:
+ new_wp->pipe_off = 0;
+ new_wp->flags &= ~PANE_EXITED;
+
+ sigprocmask(SIG_SETMASK, &oldset, NULL);
+ window_pane_set_event(new_wp);
+
+ if (sc->flags & SPAWN_RESPAWN)
+ return (new_wp);
+ if ((~sc->flags & SPAWN_DETACHED) || w->active == NULL) {
+ if (sc->flags & SPAWN_NONOTIFY)
+ window_set_active_pane(w, new_wp, 0);
+ else
+ window_set_active_pane(w, new_wp, 1);
+ }
+ if (~sc->flags & SPAWN_NONOTIFY)
+ notify_window("window-layout-changed", w);
+ return (new_wp);
}