aboutsummaryrefslogtreecommitdiff
path: root/src/rc
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-04-02 23:55:19 +0000
committerRoy Marples <roy@marples.name>2009-04-02 23:55:19 +0000
commitdea9e11a693527925ecaf007056ae7653d935dfd (patch)
tree686a4392e91428663cd262b7ed673ed63a1e5914 /src/rc
parent0b12faed7ff0b699565539bf1146b1977a4b9b67 (diff)
When logging, stdout isn't always a tty, which is the case for VPS
systems, Thanks to mwrobel - fixes #106.
Diffstat (limited to 'src/rc')
-rw-r--r--src/rc/rc-logger.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
index cf218ec8..697ebddd 100644
--- a/src/rc/rc-logger.c
+++ b/src/rc/rc-logger.c
@@ -150,9 +150,6 @@ void rc_logger_open(const char *level)
int i;
FILE *log = NULL;
- if (!isatty(STDOUT_FILENO))
- return;
-
if (!rc_conf_yesno("rc_logger"))
return;
@@ -163,12 +160,14 @@ void rc_logger_open(const char *level)
fcntl (signal_pipe[i], F_SETFD, s | FD_CLOEXEC) == -1))
eerrorx("fcntl: %s", strerror (errno));
- tcgetattr(STDOUT_FILENO, &tt);
- ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
-
- /* /dev/pts may not be available yet */
- if (openpty(&rc_logger_tty, &slave_tty, NULL, &tt, &ws))
- return;
+ if (isatty(STDOUT_FILENO)) {
+ tcgetattr(STDOUT_FILENO, &tt);
+ ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
+ if (openpty(&rc_logger_tty, &slave_tty, NULL, &tt, &ws))
+ return;
+ } else
+ if (openpty(&rc_logger_tty, &slave_tty, NULL, NULL, NULL))
+ return;
if ((s = fcntl(rc_logger_tty, F_GETFD, 0)) == 0)
fcntl(rc_logger_tty, F_SETFD, s | FD_CLOEXEC);