summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authornicm <nicm>2013-10-10 12:28:08 +0000
committernicm <nicm>2013-10-10 12:28:08 +0000
commit7936ce38749a4751120c856a112ee85122df612c (patch)
tree4d7fcda69120a584a3723b91df1de09ffa30a79f /client.c
parentb8b85fbb0c6cf4e9a3fa650ec7dc5036a1b0b01a (diff)
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.
Diffstat (limited to 'client.c')
-rw-r--r--client.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/client.c b/client.c
index e1bd47c2..0d57b793 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");
@@ -582,6 +595,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:
@@ -613,11 +627,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;