Update of /cvsroot/tmux/tmux
In directory vz-cvs-2.sog:/tmp/cvs-serv15895

Modified Files:
        client.c cmd-detach-client.c tmux.1 tmux.h 
Log Message:
Sync OpenBSD patchset 863:

Add a -P option to detach to HUP the client's parent process (usually
causing it to exit as well).


Index: client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/client.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- client.c    21 Jan 2011 23:44:13 -0000      1.101
+++ client.c    19 Mar 2011 23:27:35 -0000      1.102
@@ -36,6 +36,7 @@
 struct event   client_event;
 const char     *client_exitmsg;
 int            client_exitval;
+enum msgtype   client_exittype;
 int            client_attached;
 
 int            client_connect(char *, int);
@@ -100,6 +101,7 @@
        struct cmd_list         *cmdlist;
        struct msg_command_data  cmddata;
        int                      cmdflags, fd;
+       pid_t                    ppid;
        enum msgtype             msg;
        char                    *cause;
 
@@ -194,8 +196,14 @@
        event_dispatch();
 
        /* Print the exit message, if any, and exit. */
-       if (client_attached && client_exitmsg != NULL && !login_shell)
-               printf("[%s]\n", client_exitmsg);
+       if (client_attached) {
+               if (client_exitmsg != NULL && !login_shell)
+                       printf("[%s]\n", client_exitmsg);
+
+               ppid = getppid();
+               if (client_exittype == MSG_DETACHKILL && ppid > 1)
+                       kill(ppid, SIGHUP);
+       }
        return (client_exitval);
 }
 
@@ -436,12 +444,17 @@
 
                log_debug("client got %d", imsg.hdr.type);
                switch (imsg.hdr.type) {
+               case MSG_DETACHKILL:
                case MSG_DETACH:
                        if (datalen != 0)
                                fatalx("bad MSG_DETACH size");
 
+                       client_exittype = imsg.hdr.type;
+                       if (imsg.hdr.type == MSG_DETACHKILL)
+                               client_exitmsg = "detached and SIGHUP";
+                       else
+                               client_exitmsg = "detached";
                        client_write_server(MSG_EXITING, NULL, 0);
-                       client_exitmsg = "detached";
                        break;
                case MSG_EXIT:
                        if (datalen != 0 &&

Index: cmd-detach-client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-detach-client.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cmd-detach-client.c 7 Jan 2011 14:45:34 -0000       1.12
+++ cmd-detach-client.c 19 Mar 2011 23:27:35 -0000      1.13
@@ -28,8 +28,8 @@
 
 const struct cmd_entry cmd_detach_client_entry = {
        "detach-client", "detach",
-       "t:", 0, 0,
-       CMD_TARGET_CLIENT_USAGE,
+       "t:P", 0, 0,
+       "[-P] " CMD_TARGET_CLIENT_USAGE,
        CMD_READONLY,
        NULL,
        NULL,
@@ -45,7 +45,10 @@
        if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
                return (-1);
 
-       server_write_client(c, MSG_DETACH, NULL, 0);
+       if (args_has(args, 'P'))
+               server_write_client(c, MSG_DETACHKILL, NULL, 0);
+       else
+               server_write_client(c, MSG_DETACH, NULL, 0);
 
        return (0);
 }

Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.610
retrieving revision 1.611
diff -u -d -r1.610 -r1.611
--- tmux.h      15 Feb 2011 15:20:03 -0000      1.610
+++ tmux.h      19 Mar 2011 23:27:35 -0000      1.611
@@ -371,6 +371,7 @@
        MSG_SHELL,
        MSG_STDERR,
        MSG_STDOUT,
+       MSG_DETACHKILL
 };
 
 /*

Index: tmux.1
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.1,v
retrieving revision 1.295
retrieving revision 1.296
diff -u -d -r1.295 -r1.296
--- tmux.1      21 Jan 2011 23:55:26 -0000      1.295
+++ tmux.1      19 Mar 2011 23:27:35 -0000      1.296
@@ -554,10 +554,17 @@
 .Ic attach-session
 will attempt to start it; this will fail unless sessions are created in the
 configuration file.
-.It Ic detach-client Op Fl t Ar target-client
+.It Xo Ic detach-client
+.Op Fl P
+.Op Fl t Ar target-client
+.Xc
 .D1 (alias: Ic detach )
 Detach the current client if bound to a key, or the specified client with
 .Fl t .
+If
+.Fl P
+is given, send SIGHUP to the parent process of the client, typically causing it
+to exit.
 .It Ic has-session Op Fl t Ar target-session
 .D1 (alias: Ic has )
 Report an error and exit with 1 if the specified session does not exist.


------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to