Yes we could do that, try this:

Index: client.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/client.c,v
retrieving revision 1.47
diff -u -p -r1.47 client.c
--- client.c    8 Jan 2011 01:52:36 -0000       1.47
+++ client.c    14 Feb 2011 20:15:41 -0000
@@ -36,6 +36,7 @@ struct imsgbuf        client_ibuf;
 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 @@ client_main(int argc, char **argv, int f
        struct cmd_list         *cmdlist;
        struct msg_command_data  cmddata;
        int                      cmdflags, fd;
+       pid_t                    ppid;
        enum msgtype             msg;
        char                    *cause;
 
@@ -194,6 +196,8 @@ client_main(int argc, char **argv, int f
        /* Print the exit message, if any, and exit. */
        if (client_attached && client_exitmsg != NULL && !login_shell)
                printf("[%s]\n", client_exitmsg);
+       if (client_exittype == MSG_DETACHKILL && (ppid = getppid()) > 1)
+               kill(ppid, SIGHUP);
        return (client_exitval);
 }
 
@@ -434,12 +438,17 @@ client_dispatch_attached(void)
 
                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, killing parent";
+                       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: /cvs/src/usr.bin/tmux/cmd-detach-client.c,v
retrieving revision 1.6
diff -u -p -r1.6 cmd-detach-client.c
--- cmd-detach-client.c 4 Jan 2011 00:42:46 -0000       1.6
+++ cmd-detach-client.c 14 Feb 2011 20:14:07 -0000
@@ -28,8 +28,8 @@ int   cmd_detach_client_exec(struct cmd *,
 
 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 @@ cmd_detach_client_exec(struct cmd *self,
        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: server-client.c
===================================================================
RCS file: /cvs/src/usr.bin/tmux/server-client.c,v
retrieving revision 1.51
diff -u -p -r1.51 server-client.c
--- server-client.c     26 Jan 2011 01:54:56 -0000      1.51
+++ server-client.c     14 Feb 2011 13:21:13 -0000
@@ -403,6 +403,7 @@ server_client_loop(void)
 
                server_client_check_exit(c);
                if (c->session != NULL) {
+                       server_client_check_backoff(c); /* before redraw */
                        server_client_check_redraw(c);
                        server_client_reset_state(c);
                }
Index: tmux.1
===================================================================
RCS file: /cvs/src/usr.bin/tmux/tmux.1,v
retrieving revision 1.210
diff -u -p -r1.210 tmux.1
--- tmux.1      14 Jan 2011 23:49:23 -0000      1.210
+++ tmux.1      14 Feb 2011 20:17:49 -0000
@@ -550,10 +550,17 @@ If no server is started,
 .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.
Index: tmux.h
===================================================================
RCS file: /cvs/src/usr.bin/tmux/tmux.h,v
retrieving revision 1.271
diff -u -p -r1.271 tmux.h
--- tmux.h      26 Jan 2011 01:54:56 -0000      1.271
+++ tmux.h      14 Feb 2011 20:14:14 -0000
@@ -375,6 +375,7 @@ enum msgtype {
        MSG_SHELL,
        MSG_STDERR,
        MSG_STDOUT,
+       MSG_DETACHKILL
 };
 
 /*



On Mon, Feb 14, 2011 at 11:51:45AM -0800, Steve Mayer wrote:
>    Nicholas Marriott wrote:
> 
>  What does it do?
> 
> 
>  On Mon, Feb 14, 2011 at 11:26:15AM -0800, Steve Mayer wrote:
> 
>     Hello,
> 
>       Just wondering if there currently exists (or is planned) any support for
>     an equivalent to the 'pow_detach' command/feature of screen?
> 
>     Thanks,
>     Steve Mayer
> 
> 
>  
> ------------------------------------------------------------------------------
>  The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
>  Pinpoint memory and threading errors before they happen.
>  Find and fix more than 250 security defects in the development cycle.
>  Locate bottlenecks in serial and parallel code that limit performance.
>  [1]http://p.sf.net/sfu/intel-dev2devfeb
> 
> 
>  _______________________________________________
>  tmux-users mailing list
>  [2]tmux-users@lists.sourceforge.net
>  [3]https://lists.sourceforge.net/lists/listinfo/tmux-users
> 
> 
>    What it does is basically a 'detach and logout'.  For instance, when I'm
>    ssh'd into a host and I want to detach, but not be dropped out to the
>    shell on the remote host (but rather close the ssh session altogether),
>    when using screen, I can use the 'pow_detach' feature.
> 
>    With tmux, there doesn't currently appear to be a way to do this.  I'm
>    sure there's some combination of shell routines I could throw together,
>    but was hoping for some equivalent functionality from tmux itself.
> 
>    Thanks,
> 
>    Steve Mayer
> 
> References
> 
>    Visible links
>    1. http://p.sf.net/sfu/intel-dev2devfeb
>    2. mailto:tmux-users@lists.sourceforge.net
>    3. https://lists.sourceforge.net/lists/listinfo/tmux-users

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to