Ticket #106: rc-logger-tty.2.patch

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

     
    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                if (openpty(&rc_logger_tty, &slave_tty, NULL, NULL, NULL)) 
     174                        return; 
    172175 
    173176        if ((s = fcntl(rc_logger_tty, F_GETFD, 0)) == 0) 
    174177                fcntl(rc_logger_tty, F_SETFD, s | FD_CLOEXEC);