Add -s option to detach all clients attached to a session, from Zac

Sprackett.
This commit is contained in:
Nicholas Marriott 2011-04-11 06:44:56 +00:00
parent 75f218dc73
commit 457147d59d
2 changed files with 31 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $Id: cmd-detach-client.c,v 1.13 2011-03-19 23:27:35 tcunha Exp $ */ /* $Id: cmd-detach-client.c,v 1.14 2011-04-11 06:44:56 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -28,7 +28,7 @@ int cmd_detach_client_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_detach_client_entry = { const struct cmd_entry cmd_detach_client_entry = {
"detach-client", "detach", "detach-client", "detach",
"t:P", 0, 0, "s:t:P", 0, 0,
"[-P] " CMD_TARGET_CLIENT_USAGE, "[-P] " CMD_TARGET_CLIENT_USAGE,
CMD_READONLY, CMD_READONLY,
NULL, NULL,
@ -41,14 +41,32 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
{ {
struct args *args = self->args; struct args *args = self->args;
struct client *c; struct client *c;
struct session *s;
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL) enum msgtype msgtype;
return (-1); u_int i;
if (args_has(args, 'P')) if (args_has(args, 'P'))
server_write_client(c, MSG_DETACHKILL, NULL, 0); msgtype = MSG_DETACHKILL;
else else
server_write_client(c, MSG_DETACH, NULL, 0); msgtype = MSG_DETACH;
if (args_has(args, 's')) {
s = cmd_find_session(ctx, args_get(args, 's'), 0);
if (s == NULL)
return (-1);
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL && c->session == s)
server_write_client(c, msgtype, NULL, 0);
}
} else {
c = cmd_find_client(ctx, args_get(args, 't'));
if (c == NULL)
return (-1);
server_write_client(c, msgtype, NULL, 0);
}
return (0); return (0);
} }

9
tmux.1
View File

@ -1,4 +1,4 @@
.\" $Id: tmux.1,v 1.303 2011-04-06 22:31:23 nicm Exp $ .\" $Id: tmux.1,v 1.304 2011-04-11 06:44:56 nicm Exp $
.\" .\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\" .\"
@ -580,10 +580,13 @@ session.
.It Xo Ic detach-client .It Xo Ic detach-client
.Op Fl P .Op Fl P
.Op Fl t Ar target-client .Op Fl t Ar target-client
.Op Fl s Ar target-session
.Xc .Xc
.D1 (alias: Ic detach ) .D1 (alias: Ic detach )
Detach the current client if bound to a key, or the specified client with Detach the current client if bound to a key, the client specified with
.Fl t . .Fl t ,
or all clients currently attached to to the session specified by
.Fl s .
If If
.Fl P .Fl P
is given, send SIGHUP to the parent process of the client, typically causing it is given, send SIGHUP to the parent process of the client, typically causing it