[BACK]Return to client.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/client.c between version 1.51 and 1.52

version 1.51, 2012/03/24 11:23:19 version 1.52, 2012/04/23 23:18:43
Line 35 
Line 35 
   
 struct imsgbuf  client_ibuf;  struct imsgbuf  client_ibuf;
 struct event    client_event;  struct event    client_event;
 const char     *client_exitmsg;  enum {
           CLIENT_EXIT_NONE,
           CLIENT_EXIT_DETACHED,
           CLIENT_EXIT_DETACHED_HUP,
           CLIENT_EXIT_LOST_TTY,
           CLIENT_EXIT_TERMINATED,
           CLIENT_EXIT_LOST_SERVER,
           CLIENT_EXIT_EXITED,
           CLIENT_EXIT_SERVER_EXITED,
   } client_exitreason = CLIENT_EXIT_NONE;
 int             client_exitval;  int             client_exitval;
 enum msgtype    client_exittype;  enum msgtype    client_exittype;
 int             client_attached;  int             client_attached;
Line 121 
Line 130 
         return (-1);          return (-1);
 }  }
   
   /* Get exit string from reason number. */
   const char *
   client_exit_message(void)
   {
           switch (client_exitreason) {
           case CLIENT_EXIT_NONE:
                   break;
           case CLIENT_EXIT_DETACHED:
                   return ("detached");
           case CLIENT_EXIT_DETACHED_HUP:
                   return ("detached and SIGHUP");
           case CLIENT_EXIT_LOST_TTY:
                   return ("lost tty");
           case CLIENT_EXIT_TERMINATED:
                   return ("terminated");
           case CLIENT_EXIT_LOST_SERVER:
                   return ("lost server");
           case CLIENT_EXIT_EXITED:
                   return ("exited");
           case CLIENT_EXIT_SERVER_EXITED:
                   return ("server exited");
           }
           return ("unknown reason");
   }
   
 /* Client main loop. */  /* Client main loop. */
 int  int
 client_main(int argc, char **argv, int flags)  client_main(int argc, char **argv, int flags)
Line 170 
Line 204 
          * if the socket path matches $TMUX, this is probably the same server.           * if the socket path matches $TMUX, this is probably the same server.
          */           */
         if (shell_cmd == NULL && environ_path != NULL &&          if (shell_cmd == NULL && environ_path != NULL &&
             cmdflags & CMD_CANTNEST && strcmp(socket_path, environ_path) == 0) {              (cmdflags & CMD_CANTNEST) &&
               strcmp(socket_path, environ_path) == 0) {
                 log_warnx("sessions should be nested with care. "                  log_warnx("sessions should be nested with care. "
                     "unset $TMUX to force.");                      "unset $TMUX to force.");
                 return (1);                  return (1);
Line 223 
Line 258 
   
         /* Print the exit message, if any, and exit. */          /* Print the exit message, if any, and exit. */
         if (client_attached) {          if (client_attached) {
                 if (client_exitmsg != NULL && !login_shell)                  if (client_exitreason != CLIENT_EXIT_NONE && !login_shell)
                         printf("[%s]\n", client_exitmsg);                          printf("[%s]\n", client_exit_message());
   
                 ppid = getppid();                  ppid = getppid();
                 if (client_exittype == MSG_DETACHKILL && ppid > 1)                  if (client_exittype == MSG_DETACHKILL && ppid > 1)
Line 323 
Line 358 
         } else {          } else {
                 switch (sig) {                  switch (sig) {
                 case SIGHUP:                  case SIGHUP:
                         client_exitmsg = "lost tty";                          client_exitreason = CLIENT_EXIT_LOST_TTY;
                         client_exitval = 1;                          client_exitval = 1;
                         client_write_server(MSG_EXITING, NULL, 0);                          client_write_server(MSG_EXITING, NULL, 0);
                         break;                          break;
                 case SIGTERM:                  case SIGTERM:
                         client_exitmsg = "terminated";                          client_exitreason = CLIENT_EXIT_TERMINATED;
                         client_exitval = 1;                          client_exitval = 1;
                         client_write_server(MSG_EXITING, NULL, 0);                          client_write_server(MSG_EXITING, NULL, 0);
                         break;                          break;
Line 380 
Line 415 
         return;          return;
   
 lost_server:  lost_server:
         client_exitmsg = "lost server";          client_exitreason = CLIENT_EXIT_LOST_SERVER;
         client_exitval = 1;          client_exitval = 1;
         event_loopexit(NULL);          event_loopexit(NULL);
 }  }
Line 477 
Line 512 
   
                         client_exittype = imsg.hdr.type;                          client_exittype = imsg.hdr.type;
                         if (imsg.hdr.type == MSG_DETACHKILL)                          if (imsg.hdr.type == MSG_DETACHKILL)
                                 client_exitmsg = "detached and SIGHUP";                                  client_exitreason = CLIENT_EXIT_DETACHED_HUP;
                         else                          else
                                 client_exitmsg = "detached";                                  client_exitreason = CLIENT_EXIT_DETACHED;
                         client_write_server(MSG_EXITING, NULL, 0);                          client_write_server(MSG_EXITING, NULL, 0);
                         break;                          break;
                 case MSG_EXIT:                  case MSG_EXIT:
Line 488 
Line 523 
                                 fatalx("bad MSG_EXIT size");                                  fatalx("bad MSG_EXIT size");
   
                         client_write_server(MSG_EXITING, NULL, 0);                          client_write_server(MSG_EXITING, NULL, 0);
                         client_exitmsg = "exited";                          client_exitreason = CLIENT_EXIT_EXITED;
                         break;                          break;
                 case MSG_EXITED:                  case MSG_EXITED:
                         if (datalen != 0)                          if (datalen != 0)
Line 501 
Line 536 
                                 fatalx("bad MSG_SHUTDOWN size");                                  fatalx("bad MSG_SHUTDOWN size");
   
                         client_write_server(MSG_EXITING, NULL, 0);                          client_write_server(MSG_EXITING, NULL, 0);
                         client_exitmsg = "server exited";                          client_exitreason = CLIENT_EXIT_SERVER_EXITED;
                         client_exitval = 1;                          client_exitval = 1;
                         break;                          break;
                 case MSG_SUSPEND:                  case MSG_SUSPEND:

Legend:
Removed from v.1.51  
changed lines
  Added in v.1.52