diff options
author | Yaroslav Tykhiy <ytykhiy@gmail.com> | 2007-06-15 10:10:40 +0000 |
---|---|---|
committer | Yaroslav Tykhiy <ytykhiy@gmail.com> | 2007-06-15 10:10:40 +0000 |
commit | 287303f0ea9256244004fb559b3ba0e1c48b5fc1 (patch) | |
tree | 0cf4f0b23b39d0349e39ff79da38da3b350b7334 /libexec/atrun | |
parent | db062bd2e6fda34503bf8adb3170eb192495ed96 (diff) | |
download | src-test2-287303f0ea9256244004fb559b3ba0e1c48b5fc1.tar.gz src-test2-287303f0ea9256244004fb559b3ba0e1c48b5fc1.zip |
Notes
Diffstat (limited to 'libexec/atrun')
-rw-r--r-- | libexec/atrun/atrun.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/libexec/atrun/atrun.c b/libexec/atrun/atrun.c index 9881415637a9..977eaa0cfee7 100644 --- a/libexec/atrun/atrun.c +++ b/libexec/atrun/atrun.c @@ -41,6 +41,7 @@ static const char rcsid[] = #include <grp.h> #include <pwd.h> #include <signal.h> +#include <stdarg.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> @@ -88,7 +89,8 @@ static const char rcsid[] = static int debug = 0; -void perr(const char *a); +void perr(const char *fmt, ...); +void perrx(const char *fmt, ...); static void usage(void); /* Local functions */ @@ -384,14 +386,38 @@ run_file(const char *filename, uid_t uid, gid_t gid) /* Needed in gloadavg.c */ void -perr(const char *a) +perr(const char *fmt, ...) { + const char * const fmtadd = ": %m"; + char nfmt[strlen(fmt) + strlen(fmtadd) + 1]; + va_list ap; + + va_start(ap, fmt); if (debug) { - warn("%s", a); + vwarn(fmt, ap); + } + else + { + snprintf(nfmt, sizeof(nfmt), "%s%s", fmt, fmtadd); + vsyslog(LOG_ERR, nfmt, ap); } + va_end(ap); + + exit(EXIT_FAILURE); +} + +void +perrx(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if (debug) + vwarnx(fmt, ap); else - syslog(LOG_ERR, "%s: %m", a); + vsyslog(LOG_ERR, fmt, ap); + va_end(ap); exit(EXIT_FAILURE); } |