summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/server.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2014-09-01 21:58:42 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2014-09-01 21:58:42 +0000
commit949717853b92ea4e233b12b50cda29cb1c2a4e12 (patch)
treec82348d6cdf3adf2a8500234540436b5929ce661 /usr.bin/tmux/server.c
parentd82fa19b3bdaf8f57b6db96d34d238863e18c7ff (diff)
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) {