When logging, stdout isn't always a tty, which is the case for VPS
systems, Thanks to mwrobel - fixes #106.
This commit is contained in:
parent
0b12faed7f
commit
dea9e11a69
@ -150,9 +150,6 @@ void rc_logger_open(const char *level)
|
|||||||
int i;
|
int i;
|
||||||
FILE *log = NULL;
|
FILE *log = NULL;
|
||||||
|
|
||||||
if (!isatty(STDOUT_FILENO))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!rc_conf_yesno("rc_logger"))
|
if (!rc_conf_yesno("rc_logger"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -163,12 +160,14 @@ void rc_logger_open(const char *level)
|
|||||||
fcntl (signal_pipe[i], F_SETFD, s | FD_CLOEXEC) == -1))
|
fcntl (signal_pipe[i], F_SETFD, s | FD_CLOEXEC) == -1))
|
||||||
eerrorx("fcntl: %s", strerror (errno));
|
eerrorx("fcntl: %s", strerror (errno));
|
||||||
|
|
||||||
|
if (isatty(STDOUT_FILENO)) {
|
||||||
tcgetattr(STDOUT_FILENO, &tt);
|
tcgetattr(STDOUT_FILENO, &tt);
|
||||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
|
ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
|
||||||
|
|
||||||
/* /dev/pts may not be available yet */
|
|
||||||
if (openpty(&rc_logger_tty, &slave_tty, NULL, &tt, &ws))
|
if (openpty(&rc_logger_tty, &slave_tty, NULL, &tt, &ws))
|
||||||
return;
|
return;
|
||||||
|
} else
|
||||||
|
if (openpty(&rc_logger_tty, &slave_tty, NULL, NULL, NULL))
|
||||||
|
return;
|
||||||
|
|
||||||
if ((s = fcntl(rc_logger_tty, F_GETFD, 0)) == 0)
|
if ((s = fcntl(rc_logger_tty, F_GETFD, 0)) == 0)
|
||||||
fcntl(rc_logger_tty, F_SETFD, s | FD_CLOEXEC);
|
fcntl(rc_logger_tty, F_SETFD, s | FD_CLOEXEC);
|
||||||
|
Loading…
Reference in New Issue
Block a user