[1542] in Moira
update_server should syslog
daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Wed May 3 20:33:20 2000
Message-Id: <200005040033.UAA02061@RIFF-RAFF-W20.MIT.EDU>
To: moiradev@MIT.EDU
Date: Wed, 03 May 2000 20:33:18 -0400
From: Garry Zacheiss <zacheiss@MIT.EDU>
rather than spewing to the console. This should prevent a lot
of Sun console lossage.
Index: update_server.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/update/update_server.c,v
retrieving revision 1.21
diff -c -r1.21 update_server.c
*** update_server.c 1998/11/09 22:48:18 1.21
--- update_server.c 2000/05/03 23:04:27
***************
*** 23,28 ****
--- 23,29 ----
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+ #include <syslog.h>
#include <des.h>
#include "update.h"
***************
*** 36,41 ****
--- 37,44 ----
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,122 ****
--- 120,128 ----
exit(1);
}
+ set_com_err_hook(syslog_com_err_proc);
+ openlog(whoami, LOG_PID, LOG_DAEMON);
+
/* now loop waiting for connections */
while (1)
{
***************
*** 227,230 ****
--- 233,249 ----
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);
}