diff options
author | 2021-01-04 08:43:16 +0000 | |
---|---|---|
committer | 2021-01-04 08:43:16 +0000 | |
commit | c93e2546f4cfc8707fb69bb64a16b7d99742a300 (patch) | |
tree | c829c9f316f7b465b9a37fcc29e360cb5866b7f4 | |
parent | Remove BER_TYPE_BOOLEAN, it's not part of the spec and I haven't seen it (diff) | |
download | wireguard-openbsd-c93e2546f4cfc8707fb69bb64a16b7d99742a300.tar.xz wireguard-openbsd-c93e2546f4cfc8707fb69bb64a16b7d99742a300.zip |
Add a variant of remain-on-exit that only keeps the pane if the program
failed, GitHub issue 2513.
-rw-r--r-- | usr.bin/tmux/options-table.c | 10 | ||||
-rw-r--r-- | usr.bin/tmux/server-fn.c | 18 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 9 |
3 files changed, 26 insertions, 11 deletions
diff --git a/usr.bin/tmux/options-table.c b/usr.bin/tmux/options-table.c index 1ea2b19aad5..ed511153523 100644 --- a/usr.bin/tmux/options-table.c +++ b/usr.bin/tmux/options-table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options-table.c,v 1.136 2020/12/15 08:31:50 nicm Exp $ */ +/* $OpenBSD: options-table.c,v 1.137 2021/01/04 08:43:16 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -69,6 +69,9 @@ static const char *options_table_set_clipboard_list[] = { static const char *options_table_window_size_list[] = { "largest", "smallest", "manual", "latest", NULL }; +static const char *options_table_remain_on_exit_list[] = { + "off", "on", "failed", NULL +}; /* Status line format. */ #define OPTIONS_TABLE_STATUS_FORMAT1 \ @@ -949,11 +952,12 @@ const struct options_table_entry options_table[] = { }, { .name = "remain-on-exit", - .type = OPTIONS_TABLE_FLAG, + .type = OPTIONS_TABLE_CHOICE, .scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE, + .choices = options_table_remain_on_exit_list, .default_num = 0, .text = "Whether panes should remain ('on') or be automatically " - "killed ('off') when the program inside exits." + "killed ('off' or 'failed') when the program inside exits." }, { .name = "synchronize-panes", diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c index 8ecb56ae237..6ad70961b0d 100644 --- a/usr.bin/tmux/server-fn.c +++ b/usr.bin/tmux/server-fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-fn.c,v 1.128 2020/07/30 07:32:52 nicm Exp $ */ +/* $OpenBSD: server-fn.c,v 1.129 2021/01/04 08:43:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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; diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 2678c04d1eb..859717d090b 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.809 2021/01/01 08:36:51 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.810 2021/01/04 08:43:16 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 1 2021 $ +.Dd $Mdocdate: January 4 2021 $ .Dt TMUX 1 .Os .Sh NAME @@ -4181,10 +4181,13 @@ interactive application starts and restores it on exit, so that any output visible before the application starts reappears unchanged after it exits. .Pp .It Xo Ic remain-on-exit -.Op Ic on | off +.Op Ic on | off | failed .Xc A pane with this flag set is not destroyed when the program running in it exits. +If set to +.Ic failed , +then only when the program exit status is not zero. The pane may be reactivated with the .Ic respawn-pane command. |