Ticket #106: rc-logger-tty.patch

File rc-logger-tty.patch, 1.3 KB (added by mwrobel, 17 months ago)
  • src/rc/rc-logger.c

    old new  
    150150       int i; 
    151151       FILE *log = NULL; 
    152152 
    153        if (!isatty(STDOUT_FILENO)) 
    154                return; 
    155  
    156153       if (!rc_conf_yesno("rc_logger")) 
    157154               return; 
    158155 
     
    163160                    fcntl (signal_pipe[i], F_SETFD, s | FD_CLOEXEC) == -1)) 
    164161                       eerrorx("fcntl: %s", strerror (errno)); 
    165162 
    166        tcgetattr(STDOUT_FILENO, &tt); 
    167        ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); 
    168  
    169        /* /dev/pts may not be available yet */ 
    170        if (openpty(&rc_logger_tty, &slave_tty, NULL, &tt, &ws)) 
    171                return; 
     163       if (isatty(STDOUT_FILENO)) 
     164       { 
     165               tcgetattr(STDOUT_FILENO, &tt); 
     166               ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); 
     167 
     168               /* /dev/pts may not be available yet */ 
     169               if (openpty(&rc_logger_tty, &slave_tty, NULL, &tt, &ws)) 
     170                       return; 
     171       } 
     172       else 
     173               /* /dev/pts may not be available yet */ 
     174               if (openpty(&rc_logger_tty, &slave_tty, NULL, NULL, NULL)) 
     175                       return; 
    172176 
    173177       if ((s = fcntl(rc_logger_tty, F_GETFD, 0)) == 0) 
    174178               fcntl(rc_logger_tty, F_SETFD, s | FD_CLOEXEC);