=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/client.c,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- src/usr.bin/tmux/client.c 2011/01/08 01:52:36 1.47 +++ src/usr.bin/tmux/client.c 2011/03/03 08:51:47 1.48 @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.47 2011/01/08 01:52:36 nicm Exp $ */ +/* $OpenBSD: client.c,v 1.48 2011/03/03 08:51:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -36,6 +36,7 @@ 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 @@ struct cmd_list *cmdlist; struct msg_command_data cmddata; int cmdflags, fd; + pid_t ppid; enum msgtype msg; char *cause; @@ -192,8 +194,14 @@ event_dispatch(); /* Print the exit message, if any, and exit. */ - if (client_attached && client_exitmsg != NULL && !login_shell) - printf("[%s]\n", client_exitmsg); + if (client_attached) { + if (client_exitmsg != NULL && !login_shell) + printf("[%s]\n", client_exitmsg); + + ppid = getppid(); + if (client_exittype == MSG_DETACHKILL && ppid > 1) + kill(ppid, SIGHUP); + } return (client_exitval); } @@ -434,12 +442,17 @@ 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 and SIGHUP"; + else + client_exitmsg = "detached"; client_write_server(MSG_EXITING, NULL, 0); - client_exitmsg = "detached"; break; case MSG_EXIT: if (datalen != 0 &&