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

This commit is contained in:
abs 2012-07-14 20:32:39 +00:00
parent 2dae1f92be
commit d149c09c58
1 changed files with 6 additions and 3 deletions

View File

@ -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 @@ syslog(int fac, const char *fmt, ...)
{
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 @@ void
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);
}