From 9a7cde0c9be168900d3914857c85d71bc472608f Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 26 Sep 2010 20:43:30 +0000 Subject: Two new options: - server option "exit-unattached" makes the server exit when no clients are attached, even if sessions are present; - session option "destroy-unattached" destroys a session once no clients are attached to it. These are useful for preventing tmux remaining in the background where it is undesirable and when using tmux as a login shell to keep a limit on new sessions. --- server-fn.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'server-fn.c') diff --git a/server-fn.c b/server-fn.c index 03c89cf5..af443e8f 100644 --- a/server-fn.c +++ b/server-fn.c @@ -404,6 +404,25 @@ server_destroy_session(struct session *s) recalculate_sizes(); } +void +server_check_unattached (void) +{ + struct session *s; + u_int i; + + /* + * If any sessions are no longer attached and have destroy-unattached + * set, collect them. + */ + for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { + s = ARRAY_ITEM(&sessions, i); + if (s == NULL || !(s->flags & SESSION_UNATTACHED)) + continue; + if (options_get_number (&s->options, "destroy-unattached")) + session_destroy(s); + } +} + void server_set_identify(struct client *c) { -- cgit