From 0d4a1e1f65e3c86eee92864b34389b751d2811fd Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 22 Feb 2018 10:54:51 +0000 Subject: [PATCH] Add exit-empty option to exit server if no sessions (defaults to on). --- usr.bin/tmux/options-table.c | 8 +++++++- usr.bin/tmux/server.c | 5 ++++- usr.bin/tmux/tmux.1 | 9 +++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/usr.bin/tmux/options-table.c b/usr.bin/tmux/options-table.c index d192e30ea4d..d1dd3ec1620 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.94 2017/10/25 14:14:52 nicm Exp $ */ +/* $OpenBSD: options-table.c,v 1.95 2018/02/22 10:54:51 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott @@ -97,6 +97,12 @@ const struct options_table_entry options_table[] = { .default_num = 500 }, + { .name = "exit-empty", + .type = OPTIONS_TABLE_FLAG, + .scope = OPTIONS_TABLE_SERVER, + .default_num = 1 + }, + { .name = "exit-unattached", .type = OPTIONS_TABLE_FLAG, .scope = OPTIONS_TABLE_SERVER, diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c index 138c06fb298..7056838b90d 100644 --- a/usr.bin/tmux/server.c +++ b/usr.bin/tmux/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.178 2017/12/19 15:00:39 nicm Exp $ */ +/* $OpenBSD: server.c,v 1.179 2018/02/22 10:54:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -255,6 +255,9 @@ server_loop(void) server_client_loop(); + if (!options_get_number(global_options, "exit-empty") && !server_exit) + return (0); + if (!options_get_number(global_options, "exit-unattached")) { if (!RB_EMPTY(&sessions)) return (0); diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 3f12be737fc..4fb28f77588 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.591 2018/01/16 09:00:38 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.592 2018/02/22 10:54:51 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -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 16 2018 $ +.Dd $Mdocdate: February 22 2018 $ .Dt TMUX 1 .Os .Sh NAME @@ -2503,6 +2503,11 @@ Set the time in milliseconds for which waits after an escape is input to determine if it is part of a function or meta key sequences. The default is 500 milliseconds. +.It Xo Ic exit-empty +.Op Ic on | off +.Xc +If enabled (the default), the server will exit when there are no active +sessions. .It Xo Ic exit-unattached .Op Ic on | off .Xc -- 2.20.1