summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/server.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2014-09-01 21:58:41 +0000
committernicm <nicm@openbsd.org>2014-09-01 21:58:41 +0000
commit7d5939e200e5c928004abbbeb4d921ac41b949cd (patch)
treebe7694b0ed0d748d7f939fd79843c9e066cd8553 /usr.bin/tmux/server.c
parentVarious minor style and spacing nits. (diff)
downloadwireguard-openbsd-7d5939e200e5c928004abbbeb4d921ac41b949cd.tar.xz
wireguard-openbsd-7d5939e200e5c928004abbbeb4d921ac41b949cd.zip
Wake up any clients waiting with the wait-for command when the server
exits.
Diffstat (limited to 'usr.bin/tmux/server.c')
-rw-r--r--usr.bin/tmux/server.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c
index 3289dc2196b..51f443873da 100644
--- a/usr.bin/tmux/server.c
+++ b/usr.bin/tmux/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.115 2014/07/21 10:52:48 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.116 2014/09/01 21:58:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -217,16 +217,30 @@ server_loop(void)
int
server_should_shutdown(void)
{
- u_int i;
+ struct client *c;
+ u_int i;
if (!options_get_number(&global_options, "exit-unattached")) {
if (!RB_EMPTY(&sessions))
return (0);
}
+
+ for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
+ c = ARRAY_ITEM(&clients, i);
+ if (c != NULL && c->session != NULL)
+ return (0);
+ }
+
+ /*
+ * No attached clients therefore want to exit - flush any waiting
+ * clients but don't actually exit until they've gone.
+ */
+ cmd_wait_for_flush();
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
if (ARRAY_ITEM(&clients, i) != NULL)
return (0);
}
+
return (1);
}
@@ -238,6 +252,8 @@ server_send_shutdown(void)
struct session *s, *next_s;
u_int i;
+ cmd_wait_for_flush();
+
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL) {