Update of /cvsroot/tmux/tmux
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv23065

Modified Files:
        cmd-set-option.c cmd-switch-client.c server-client.c 
        server-fn.c server.c tmux.1 tmux.c tmux.h 
Log Message:
Sync OpenBSD patchset 766:

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.    


Index: cmd-set-option.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-set-option.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- cmd-set-option.c    7 Sep 2010 13:20:28 -0000       1.99
+++ cmd-set-option.c    9 Oct 2010 14:29:32 -0000       1.100
@@ -75,6 +75,7 @@
 
 const struct set_option_entry set_option_table[] = {
        { "escape-time", SET_OPTION_NUMBER, 0, INT_MAX, NULL },
+       { "exit-unattached", SET_OPTION_FLAG, 0, 0, NULL },
        { "quiet", SET_OPTION_FLAG, 0, 0, NULL },
        { NULL, 0, 0, 0, NULL }
 };
@@ -87,6 +88,7 @@
        { "default-path", SET_OPTION_STRING, 0, 0, NULL },
        { "default-shell", SET_OPTION_STRING, 0, 0, NULL },
        { "default-terminal", SET_OPTION_STRING, 0, 0, NULL },
+       { "destroy-unattached", SET_OPTION_FLAG, 0, 0, NULL },
        { "detach-on-destroy", SET_OPTION_FLAG, 0, 0, NULL },
        { "display-panes-colour", SET_OPTION_COLOUR, 0, 0, NULL },
        { "display-panes-active-colour", SET_OPTION_COLOUR, 0, 0, NULL },

Index: server-client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/server-client.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- server-client.c     7 Sep 2010 13:19:53 -0000       1.41
+++ server-client.c     9 Oct 2010 14:29:32 -0000       1.42
@@ -184,6 +184,7 @@
        c->flags |= CLIENT_DEAD;
 
        recalculate_sizes();
+       server_check_unattached();
        server_update_socket();
 }
 

Index: tmux.1
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.1,v
retrieving revision 1.266
retrieving revision 1.267
diff -u -d -r1.266 -r1.267
--- tmux.1      9 Oct 2010 14:25:40 -0000       1.266
+++ tmux.1      9 Oct 2010 14:29:32 -0000       1.267
@@ -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: September 25 2010 $
+.Dd $Mdocdate: September 26 2010 $
 .Dt TMUX 1
 .Os
 .Sh NAME
@@ -1587,6 +1587,9 @@
 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 Ic exit-unattached
+If enabled, the server will exit when there are no attached clients, rather
+than when there are no attached sessions.
 .It Ic quiet
 Enable or disable the display of various informational messages (see also the
 .Fl q
@@ -1659,6 +1662,9 @@
 be set to
 .Ql screen
 or a derivative of it.
+.It Ic destroy-unattached
+If enabled and the session is no longer attached to any clients, it is
+destroyed.
 .It Ic detach-on-destroy
 If on (the default), the client is detached when the session it is attached to
 is destroyed.

Index: server-fn.c
===================================================================
RCS file: /cvsroot/tmux/tmux/server-fn.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- server-fn.c 11 Aug 2010 22:16:43 -0000      1.110
+++ server-fn.c 9 Oct 2010 14:29:32 -0000       1.111
@@ -405,6 +405,25 @@
 }
 
 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)
 {
        struct timeval  tv;

Index: cmd-switch-client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-switch-client.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- cmd-switch-client.c 10 Sep 2010 13:36:17 -0000      1.20
+++ cmd-switch-client.c 9 Oct 2010 14:29:32 -0000       1.21
@@ -152,6 +152,7 @@
        c->session = s;
 
        recalculate_sizes();
+       server_check_unattached();
        server_redraw_client(c);
 
        return (0);

Index: server.c
===================================================================
RCS file: /cvsroot/tmux/tmux/server.c,v
retrieving revision 1.244
retrieving revision 1.245
diff -u -d -r1.244 -r1.245
--- server.c    9 Oct 2010 14:26:29 -0000       1.244
+++ server.c    9 Oct 2010 14:29:32 -0000       1.245
@@ -226,15 +226,17 @@
        }
 }
 
-/* Check if the server should be shutting down (no more clients or windows). */
+/* Check if the server should be shutting down (no more clients or sessions). 
*/
 int
 server_should_shutdown(void)
 {
        u_int   i;
 
-       for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
-               if (ARRAY_ITEM(&sessions, i) != NULL)
-                       return (0);
+       if (!options_get_number(&global_options, "exit-unattached")) {
+               for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
+                       if (ARRAY_ITEM(&sessions, i) != NULL)
+                               return (0);
+               }
        }
        for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
                if (ARRAY_ITEM(&clients, i) != NULL)

Index: tmux.c
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.c,v
retrieving revision 1.215
retrieving revision 1.216
diff -u -d -r1.215 -r1.216
--- tmux.c      29 Aug 2010 14:42:11 -0000      1.215
+++ tmux.c      9 Oct 2010 14:29:32 -0000       1.216
@@ -334,6 +334,7 @@
        oo = &global_options;
        options_set_number(oo, "quiet", quiet);
        options_set_number(oo, "escape-time", 500);
+       options_set_number(oo, "exit-unattached", 0);
 
        options_init(&global_s_options, NULL);
        so = &global_s_options;
@@ -344,6 +345,7 @@
        options_set_string(so, "default-path", "%s", "");
        options_set_string(so, "default-shell", "%s", getshell());
        options_set_string(so, "default-terminal", "screen");
+       options_set_number(so, "destroy-unattached", 0);
        options_set_number(so, "detach-on-destroy", 1);
        options_set_number(so, "display-panes-active-colour", 1);
        options_set_number(so, "display-panes-colour", 4);

Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.577
retrieving revision 1.578
diff -u -d -r1.577 -r1.578
--- tmux.h      18 Sep 2010 15:43:53 -0000      1.577
+++ tmux.h      9 Oct 2010 14:29:32 -0000       1.578
@@ -1659,6 +1659,7 @@
 void    server_destroy_pane(struct window_pane *);
 void    server_destroy_session_group(struct session *);
 void    server_destroy_session(struct session *);
+void    server_check_unattached (void);
 void    server_set_identify(struct client *);
 void    server_clear_identify(struct client *);
 void    server_update_event(struct client *);


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to