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

Diff for /src/usr.bin/tmux/tty.c between version 1.33 and 1.34

version 1.33, 2009/09/23 07:25:31 version 1.34, 2009/09/23 12:03:31
Line 44 
Line 44 
 void  void
 tty_init(struct tty *tty, int fd, char *term)  tty_init(struct tty *tty, int fd, char *term)
 {  {
         int      mode;  
         char    *path;          char    *path;
   
         memset(tty, 0, sizeof *tty);          memset(tty, 0, sizeof *tty);
Line 55 
Line 54 
         else          else
                 tty->termname = xstrdup(term);                  tty->termname = xstrdup(term);
   
         if ((mode = fcntl(fd, F_GETFL)) == -1)  
                 fatal("fcntl failed");  
         if (fcntl(fd, F_SETFL, mode|O_NONBLOCK) == -1)  
                 fatal("fcntl failed");  
         if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)          if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
                 fatal("fcntl failed");                  fatal("fcntl failed");
         tty->fd = fd;          tty->fd = fd;
Line 129 
Line 124 
 tty_start_tty(struct tty *tty)  tty_start_tty(struct tty *tty)
 {  {
         struct termios   tio;          struct termios   tio;
         int              what;          int              what, mode;
   
         if (tty->fd == -1)          if (tty->fd == -1)
                 return;                  return;
   
           if ((mode = fcntl(tty->fd, F_GETFL)) == -1)
                   fatal("fcntl failed");
           if (fcntl(tty->fd, F_SETFL, mode|O_NONBLOCK) == -1)
                   fatal("fcntl failed");
   
 #if 0  #if 0
         tty_detect_utf8(tty);          tty_detect_utf8(tty);
 #endif  #endif
Line 183 
Line 183 
 tty_stop_tty(struct tty *tty)  tty_stop_tty(struct tty *tty)
 {  {
         struct winsize  ws;          struct winsize  ws;
           int             mode;
   
         if (!(tty->flags & TTY_STARTED))          if (!(tty->flags & TTY_STARTED))
                 return;                  return;
Line 193 
Line 194 
          * because the fd is invalid. Things like ssh -t can easily leave us           * because the fd is invalid. Things like ssh -t can easily leave us
          * with a dead tty.           * with a dead tty.
          */           */
           if ((mode = fcntl(tty->fd, F_GETFL)) == -1)
                   return;
           if (fcntl(tty->fd, F_SETFL, mode & ~O_NONBLOCK) == -1)
                   return;
         if (ioctl(tty->fd, TIOCGWINSZ, &ws) == -1)          if (ioctl(tty->fd, TIOCGWINSZ, &ws) == -1)
                 return;                  return;
         if (tcsetattr(tty->fd, TCSANOW, &tty->tio) == -1)          if (tcsetattr(tty->fd, TCSANOW, &tty->tio) == -1)

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34