diff options
author | H. Peter Anvin <hpa@zytor.com> | 2002-08-14 05:29:19 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2002-08-14 05:29:19 +0000 |
commit | 947da5fc534cb2c7465a52f507b0f1d6eb936346 (patch) | |
tree | b9face42799596d44a04b366ce7cceb08917d736 | |
parent | a48921e396a4c6bcf8ca96d8e735bc94c402efed (diff) | |
download | klibc-947da5fc534cb2c7465a52f507b0f1d6eb936346.tar.gz |
Add fallback to stderr should /dev/kmsg be unavailableklibc-0.35
-rw-r--r-- | klibc/syslog.c | 7 | ||||
-rw-r--r-- | syslog.c | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/klibc/syslog.c b/klibc/syslog.c index 1573ee14a4696..7432dedee3069 100644 --- a/klibc/syslog.c +++ b/klibc/syslog.c @@ -39,10 +39,15 @@ void syslog(int prio, const char *format, ...) va_list ap; char buf[BUFLEN]; int rv, len; + int fd; if ( __syslog_fd == -1 ) openlog(NULL, 0, 0); + fd = __syslog_fd; + if ( fd == -1 ) + fd = 2; /* Failed to open log, write to stderr */ + buf[0] = '<'; buf[1] = LOG_PRI(prio)+'0'; buf[2] = '>'; @@ -59,5 +64,5 @@ void syslog(int prio, const char *format, ...) if ( len > BUFLEN-1 ) len = BUFLEN-1; buf[len] = '\n'; - write(__syslog_fd, buf, len+1); + write(fd, buf, len+1); } diff --git a/syslog.c b/syslog.c index 1573ee14a4696..7432dedee3069 100644 --- a/syslog.c +++ b/syslog.c @@ -39,10 +39,15 @@ void syslog(int prio, const char *format, ...) va_list ap; char buf[BUFLEN]; int rv, len; + int fd; if ( __syslog_fd == -1 ) openlog(NULL, 0, 0); + fd = __syslog_fd; + if ( fd == -1 ) + fd = 2; /* Failed to open log, write to stderr */ + buf[0] = '<'; buf[1] = LOG_PRI(prio)+'0'; buf[2] = '>'; @@ -59,5 +64,5 @@ void syslog(int prio, const char *format, ...) if ( len > BUFLEN-1 ) len = BUFLEN-1; buf[len] = '\n'; - write(__syslog_fd, buf, len+1); + write(fd, buf, len+1); } |