From: zacheiss Date: Mon, 8 May 2000 18:28:59 +0000 (+0000) Subject: syslog instead of spewing to stdout. X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/9d3d51ad672f0e2d3961581c4675362349a3fe9d syslog instead of spewing to stdout. --- diff --git a/update/update_server.c b/update/update_server.c index a0832e6b..af0cc526 100644 --- a/update/update_server.c +++ b/update/update_server.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "update.h" @@ -36,6 +37,8 @@ des_cblock session; int uid = 0; void child_handler(int signal); +static void syslog_com_err_proc(const char *progname, long code, + const char *fmt, va_list args); struct _dt { char *str; @@ -117,6 +120,9 @@ int main(int argc, char **argv) exit(1); } + set_com_err_hook(syslog_com_err_proc); + openlog(whoami, LOG_PID, LOG_DAEMON); + /* now loop waiting for connections */ while (1) { @@ -228,3 +234,16 @@ void child_handler(int signal) while (waitpid(-1, &status, WNOHANG) > 0) ; } + +static void syslog_com_err_proc(const char *progname, long code, + const char *fmt, va_list args) +{ + char *buf; + int bufsiz = 1024; + + buf = malloc(bufsiz + 1); + buf[bufsiz] = '\0'; + + vsnprintf(buf, bufsiz, fmt, args); + syslog(LOG_NOTICE, buf); +}