From ae6c4e57c4eda13956a9e5efe0956fd5c90e3a7c Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 4 Feb 1999 19:11:11 +0000 Subject: fixes --- src/initlog.c | 59 ++++++++++++++++++++++------------------------------------- 1 file changed, 22 insertions(+), 37 deletions(-) (limited to 'src/initlog.c') diff --git a/src/initlog.c b/src/initlog.c index cd787fcf..6bc6fe10 100644 --- a/src/initlog.c +++ b/src/initlog.c @@ -11,6 +11,7 @@ #define SYSLOG_NAMES #include +#include #include #define _(String) gettext((String)) @@ -86,10 +87,10 @@ int startDaemon() { if ( pid ) { /* parent */ waitpid(pid,&rc,0); - if (rc) - return -1; - else - return 0; + if (WIFEXITED(rc)) + return WEXITSTATUS(rc); + else + return -1; } else { int fd; @@ -107,44 +108,28 @@ int startDaemon() { int logLine(struct logInfo *logEnt) { /* Logs a line... somewhere. */ int x; + struct stat statbuf; /* Don't log empty or null lines */ if (!logEnt->line || !strcmp(logEnt->line,"\n")) return 0; - if ((x=access(_PATH_LOG,W_OK))) { - /* syslog isn't running, so start something... */ - if ( (x=startDaemon()) ==-1) { - logData=realloc(logData,(logEntries+1)*sizeof(struct logInfo)); - logData[logEntries]= (*logEnt); - logEntries++; - } else { - if (logEntries>0) { - for (x=0;xcmd,0,logEnt->fac); - syslog(logEnt->pri,"%s",logEnt->line); - closelog(); - } + if ( (stat(_PATH_LOG,&statbuf)==-1) && ((x=startDaemon())) ) { + logData=realloc(logData,(logEntries+1)*sizeof(struct logInfo)); + logData[logEntries]= (*logEnt); + logEntries++; } else { - if (logEntries>0) { - for (x=0;xcmd,0,logEnt->fac); - syslog(logEnt->pri,"%s",logEnt->line); - closelog(); + if (logEntries>0) { + for (x=0;xcmd,0,logEnt->fac); + syslog(logEnt->pri,"%s",logEnt->line); + closelog(); } return 0; } -- cgit