=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/client.c,v retrieving revision 1.72 retrieving revision 1.73 diff -c -r1.72 -r1.73 *** src/usr.bin/tmux/client.c 2013/10/10 12:27:38 1.72 --- src/usr.bin/tmux/client.c 2013/10/10 12:28:08 1.73 *************** *** 1,4 **** ! /* $OpenBSD: client.c,v 1.72 2013/10/10 12:27:38 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: client.c,v 1.73 2013/10/10 12:28:08 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 48,53 **** --- 48,54 ---- } 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,149 **** --- 139,162 ---- 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,587 **** --- 595,601 ---- shell_exec(data, data0); /* NOTREACHED */ case MSG_DETACH: + case MSG_DETACHKILL: client_write_server(MSG_EXITING, NULL, 0); break; case MSG_EXITED: *************** *** 613,623 **** 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"); client_exittype = imsg.hdr.type; if (imsg.hdr.type == MSG_DETACHKILL) client_exitreason = CLIENT_EXIT_DETACHED_HUP; --- 627,638 ---- log_debug("got %d from server", imsg.hdr.type); switch (imsg.hdr.type) { case MSG_DETACH: ! 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;