1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
Descriptio: logging to stderr
output is slightly different from glibc (timestamp added)
Index: b/usr/src/lib/libc/port/gen/syslog.c
===================================================================
--- a/usr/src/lib/libc/port/gen/syslog.c
+++ b/usr/src/lib/libc/port/gen/syslog.c
@@ -338,9 +338,7 @@ vsyslog(int pri, const char *fmt, va_lis
dat.buf = outline;
/* output the message to the local logger */
- if ((putmsg(LogFile, &ctl, &dat, 0) >= 0) && syslogd_ok())
- return;
- if (!(LogStat & LOG_CONS))
+ if ((putmsg(LogFile, &ctl, &dat, 0) >= 0) && syslogd_ok() && !(LogStat & LOG_PERROR))
return;
/*
@@ -353,6 +351,15 @@ vsyslog(int pri, const char *fmt, va_lis
clen = strlen(outline) + 1;
+ if (LogStat & LOG_PERROR)
+ {
+ outline[clen - 1] = '\n';
+ (void) write(STDERR_FILENO, outline, clen);
+ }
+
+ if (!(LogStat & LOG_CONS))
+ return;
+
nowait = (LogStat & LOG_NOWAIT);
pid = forkx(nowait? 0 : (FORK_NOSIGCHLD | FORK_WAITPID));
if (pid == -1)
Index: b/usr/src/head/syslog.h
===================================================================
--- a/usr/src/head/syslog.h
+++ b/usr/src/head/syslog.h
@@ -33,6 +33,10 @@
#include <sys/syslog.h>
#include <sys/va_list.h>
+#ifndef LOG_PERROR
+#define LOG_PERROR 0x20
+#endif
+
#define LOG_PRI(p) ((p) & LOG_PRIMASK)
#define LOG_MAKEPRI(fac, pri) ((fac) | (pri))
|