The branch, master has been updated
via aa0a57fd5681ffbae652bebebea04e1d90ac40ce (commit)
via d86c70af965c862651017ab4c288160f37ec654b (commit)
from 4538c269d0b366a770a5a5ebfe0c5007569edbc1 (commit)
- Log -----------------------------------------------------------------
commit aa0a57fd5681ffbae652bebebea04e1d90ac40ce
Author: Nicholas Marriott <[email protected]>
Commit: Nicholas Marriott <[email protected]>
Show session name in detached message. Requested by somebody a few months
ago
who didn't bother testing it. But it works for me anyway.
---
client.c | 21 ++++++++++++++++++---
cmd-attach-session.c | 10 +++++++---
cmd-detach-client.c | 22 +++++++++++++++-------
3 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/client.c b/client.c
index 90bd40c..8884f63 100644
--- a/client.c
+++ b/client.c
@@ -48,6 +48,7 @@ enum {
} client_exitreason = CLIENT_EXIT_NONE;
int client_exitval;
enum msgtype client_exittype;
+const char *client_exitsession;
int client_attached;
int client_get_lock(char *);
@@ -138,12 +139,24 @@ failed:
const char *
client_exit_message(void)
{
+ static char msg[256];
+
switch (client_exitreason) {
case CLIENT_EXIT_NONE:
break;
case CLIENT_EXIT_DETACHED:
+ if (client_exitsession != NULL) {
+ xsnprintf(msg, sizeof msg, "detached "
+ "(from session %s)", client_exitsession);
+ return (msg);
+ }
return ("detached");
case CLIENT_EXIT_DETACHED_HUP:
+ if (client_exitsession != NULL) {
+ xsnprintf(msg, sizeof msg, "detached and SIGHUP "
+ "(from session %s)", client_exitsession);
+ return (msg);
+ }
return ("detached and SIGHUP");
case CLIENT_EXIT_LOST_TTY:
return ("lost tty");
@@ -587,6 +600,7 @@ client_dispatch_wait(void *data0)
shell_exec(data, data0);
/* NOTREACHED */
case MSG_DETACH:
+ case MSG_DETACHKILL:
client_write_server(MSG_EXITING, NULL, 0);
break;
case MSG_EXITED:
@@ -618,11 +632,12 @@ client_dispatch_attached(void)
log_debug("got %d from server", imsg.hdr.type);
switch (imsg.hdr.type) {
- case MSG_DETACHKILL:
case MSG_DETACH:
- if (datalen != 0)
- fatalx("bad MSG_DETACH size");
+ case MSG_DETACHKILL:
+ if (datalen == 0 || data[datalen - 1] != '\0')
+ fatalx("bad MSG_DETACH string");
+ client_exitsession = xstrdup(data);
client_exittype = imsg.hdr.type;
if (imsg.hdr.type == MSG_DETACHKILL)
client_exitreason = CLIENT_EXIT_DETACHED_HUP;
diff --git a/cmd-attach-session.c b/cmd-attach-session.c
index f78a89f..e4c0b23 100644
--- a/cmd-attach-session.c
+++ b/cmd-attach-session.c
@@ -77,7 +77,9 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int
dflag, int rflag,
continue;
if (c == cmdq->client)
continue;
- server_write_client(c, MSG_DETACH, NULL, 0);
+ server_write_client(c, MSG_DETACH,
+ c->session->name,
+ strlen(c->session->name) + 1);
}
}
@@ -138,8 +140,10 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag,
int dflag, int rflag,
if (rflag)
cmdq->client->flags |= CLIENT_READONLY;
- if (dflag)
- server_write_session(s, MSG_DETACH, NULL, 0);
+ if (dflag) {
+ server_write_session(s, MSG_DETACH, s->name,
+ strlen(s->name) + 1);
+ }
update = options_get_string(&s->options, "update-environment");
environ_update(update, &cmdq->client->environ, &s->environ);
diff --git a/cmd-detach-client.c b/cmd-detach-client.c
index ea9e381..f086736 100644
--- a/cmd-detach-client.c
+++ b/cmd-detach-client.c
@@ -18,6 +18,8 @@
#include <sys/types.h>
+#include <string.h>
+
#include "tmux.h"
/*
@@ -40,8 +42,8 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
struct client *c, *c2;
- struct session *s;
- enum msgtype msgtype;
+ struct session *s;
+ enum msgtype msgtype;
u_int i;
if (args_has(args, 'P'))
@@ -56,8 +58,10 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
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);
+ if (c == NULL || c->session != s)
+ continue;
+ server_write_client(c, msgtype, c->session->name,
+ strlen(c->session->name) + 1);
}
} else {
c = cmd_find_client(cmdq, args_get(args, 't'), 0);
@@ -69,10 +73,14 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
c2 = ARRAY_ITEM(&clients, i);
if (c2 == NULL || c == c2)
continue;
- server_write_client(c2, msgtype, NULL, 0);
+ server_write_client(c2, msgtype,
+ c2->session->name,
+ strlen(c2->session->name) + 1);
}
- } else
- server_write_client(c, msgtype, NULL, 0);
+ } else {
+ server_write_client(c, msgtype, c->session->name,
+ strlen(c->session->name) + 1);
+ }
}
return (CMD_RETURN_STOP);
commit d86c70af965c862651017ab4c288160f37ec654b
Author: Nicholas Marriott <[email protected]>
Commit: Nicholas Marriott <[email protected]>
Don't look at string[length - 1] if length == 0.
---
client.c | 4 ++--
server-client.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/client.c b/client.c
index 6179187..90bd40c 100644
--- a/client.c
+++ b/client.c
@@ -580,7 +580,7 @@ client_dispatch_wait(void *data0)
imsg_free(&imsg);
return (-1);
case MSG_SHELL:
- if (data[datalen - 1] != '\0')
+ if (datalen == 0 || data[datalen - 1] != '\0')
fatalx("bad MSG_SHELL string");
clear_signals(0);
@@ -664,7 +664,7 @@ client_dispatch_attached(void)
kill(getpid(), SIGTSTP);
break;
case MSG_LOCK:
- if (data[datalen - 1] != '\0')
+ if (datalen == 0 || data[datalen - 1] != '\0')
fatalx("bad MSG_LOCK string");
system(data);
diff --git a/server-client.c b/server-client.c
index 8a99367..090916c 100644
--- a/server-client.c
+++ b/server-client.c
@@ -961,12 +961,12 @@ server_client_msg_identify(struct client *c, struct imsg
*imsg)
c->flags |= flags;
break;
case MSG_IDENTIFY_TERM:
- if (data[datalen - 1] != '\0')
+ if (datalen == 0 || data[datalen - 1] != '\0')
fatalx("bad MSG_IDENTIFY_TERM string");
c->term = xstrdup(data);
break;
case MSG_IDENTIFY_TTYNAME:
- if (data[datalen - 1] != '\0')
+ if (datalen == 0 || data[datalen - 1] != '\0')
fatalx("bad MSG_IDENTIFY_TTYNAME string");
c->ttyname = xstrdup(data);
break;
@@ -981,7 +981,7 @@ server_client_msg_identify(struct client *c, struct imsg
*imsg)
c->fd = imsg->fd;
break;
case MSG_IDENTIFY_ENVIRON:
- if (data[datalen - 1] != '\0')
+ if (datalen == 0 || data[datalen - 1] != '\0')
fatalx("bad MSG_IDENTIFY_ENVIRON string");
if (strchr(data, '=') != NULL)
environ_put(&c->environ, data);
-----------------------------------------------------------------------
Summary of changes:
client.c | 25 ++++++++++++++++++++-----
cmd-attach-session.c | 10 +++++++---
cmd-detach-client.c | 22 +++++++++++++++-------
server-client.c | 6 +++---
4 files changed, 45 insertions(+), 18 deletions(-)
hooks/post-receive
--
tmux
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs