aboutsummaryrefslogtreecommitdiff
path: root/server.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2014-10-02 09:29:48 +0100
committerNicholas Marriott <nicholas.marriott@gmail.com>2014-10-02 09:29:48 +0100
commit931c17ed4f3ac18470f5b385210d61b24a57b5d4 (patch)
tree6dbcfe073cec1ba8f34626bdfa04123b621eb9ed /server.c
parent24d9dc518de6761f645165d49f321b2b56904fb5 (diff)
parent2874a431c050527244a56e7f241baf053c722f88 (diff)
downloadrtmux-931c17ed4f3ac18470f5b385210d61b24a57b5d4.tar.gz
rtmux-931c17ed4f3ac18470f5b385210d61b24a57b5d4.tar.bz2
rtmux-931c17ed4f3ac18470f5b385210d61b24a57b5d4.zip
Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-code
Diffstat (limited to 'server.c')
-rw-r--r--server.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/server.c b/server.c
index 6cded12a..94c928db 100644
--- a/server.c
+++ b/server.c
@@ -218,16 +218,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);
}
@@ -239,6 +253,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) {