Add a variant of remain-on-exit that only keeps the pane if the program

failed, GitHub issue 2513.
This commit is contained in:
nicm
2021-01-04 08:43:16 +00:00
parent 606bd5f8c6
commit bd0fb22f0a
3 changed files with 22 additions and 7 deletions

View File

@ -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;