aboutsummaryrefslogtreecommitdiff
path: root/server-fn.c
diff options
context:
space:
mode:
authornicm <nicm>2021-01-04 08:43:16 +0000
committernicm <nicm>2021-01-04 08:43:16 +0000
commitbd0fb22f0a206a73ec3f41322571d56d9d7d7c5d (patch)
treea66752a7b2677b92bc4eec51a514b005ce0b9540 /server-fn.c
parent606bd5f8c6be326ea2e4746de5d5e007fd04eef8 (diff)
downloadrtmux-bd0fb22f0a206a73ec3f41322571d56d9d7d7c5d.tar.gz
rtmux-bd0fb22f0a206a73ec3f41322571d56d9d7d7c5d.tar.bz2
rtmux-bd0fb22f0a206a73ec3f41322571d56d9d7d7c5d.zip
Add a variant of remain-on-exit that only keeps the pane if the program
failed, GitHub issue 2513.
Diffstat (limited to 'server-fn.c')
-rw-r--r--server-fn.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/server-fn.c b/server-fn.c
index d2465569..d0e06c0f 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -314,6 +314,7 @@ server_destroy_pane(struct window_pane *wp, int notify)
struct grid_cell gc;
time_t t;
char tim[26];
+ int remain_on_exit;
if (wp->fd != -1) {
bufferevent_free(wp->event);
@@ -322,10 +323,17 @@ server_destroy_pane(struct window_pane *wp, int notify)
wp->fd = -1;
}
- if (options_get_number(wp->options, "remain-on-exit")) {
- if (~wp->flags & PANE_STATUSREADY)
- return;
-
+ remain_on_exit = options_get_number(wp->options, "remain-on-exit");
+ if (remain_on_exit != 0 && (~wp->flags & PANE_STATUSREADY))
+ return;
+ switch (remain_on_exit) {
+ case 0:
+ break;
+ case 2:
+ if (WIFEXITED(wp->status) && WEXITSTATUS(wp->status) == 0)
+ break;
+ /* FALLTHROUGH */
+ case 1:
if (wp->flags & PANE_STATUSDRAWN)
return;
wp->flags |= PANE_STATUSDRAWN;