Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/utils/libhack Add a check hack to ensure %m causes e...



details:   https://anonhg.NetBSD.org/src/rev/b22f9fb9c76d
branches:  trunk
changeset: 780189:b22f9fb9c76d
user:      abs <abs%NetBSD.org@localhost>
date:      Sat Jul 14 20:32:39 2012 +0000

description:
Add a check hack to ensure %m causes error message string to be shown

diffstat:

 distrib/utils/libhack/syslog.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r 033859afce1c -r b22f9fb9c76d distrib/utils/libhack/syslog.c
--- a/distrib/utils/libhack/syslog.c    Sat Jul 14 20:14:17 2012 +0000
+++ b/distrib/utils/libhack/syslog.c    Sat Jul 14 20:32:39 2012 +0000
@@ -1,6 +1,8 @@
 #include <sys/types.h>
 #include <sys/syslog.h>
 #include <stdio.h>
+#include <string.h>
+#include <errno.h>
 #include <stdarg.h>
 
 void
@@ -25,10 +27,8 @@
 {
        va_list ap;
        va_start(ap, fmt);
-       (void)vfprintf(stderr, fmt, ap);
+       vsyslog(fac, fmt, ap);
        va_end(ap);
-       (void)fprintf(stderr, "\n");
-       fflush(stderr);
 }
 
 __strong_alias(_vsyslog, vsyslog)
@@ -36,6 +36,9 @@
 vsyslog(int fac, const char *fmt, va_list ap)
 {
        (void)vfprintf(stderr, fmt, ap);
+       /* Cheap hack to ensure %m causes error message string to be shown */
+       if (strstr(fmt, "%m"))
+               (void)fprintf(stderr, " (%s)", strerror(errno));
        (void)fprintf(stderr, "\n");
        fflush(stderr);
 }



Home | Main Index | Thread Index | Old Index