* archival/bunzip2.c (bunzip2_main): Do not remove files if writing to standard
[oweals/busybox.git] / sysklogd / syslogd.c
index db6401c5202e581e235128438f04f176e7ba95bd..e1e71378c63a2e78e691fde1fe100fc81f7da21b 100644 (file)
@@ -81,6 +81,12 @@ static int local_logging = FALSE;
 /* circular buffer variables/structures */
 #ifdef CONFIG_FEATURE_IPC_SYSLOG
 
+#if __GNU_LIBRARY__ < 5
+#error Sorry.  Looks like you are using libc5.
+#error libc5 shm support isnt good enough.
+#error Please disable CONFIG_FEATURE_IPC_SYSLOG
+#endif
+
 #include <sys/ipc.h>
 #include <sys/sem.h>
 #include <sys/shm.h>
@@ -270,7 +276,7 @@ static void message (char *fmt, ...)
        fl.l_len    = 1;
 
 #ifdef CONFIG_FEATURE_IPC_SYSLOG
-       if ((circular_logging == TRUE) && (buf != NULL)){
+       if ((circular_logging) && (buf != NULL)){
                        char b[1024];
                        va_start (arguments, fmt);
                        vsprintf (b, fmt, arguments);
@@ -355,12 +361,14 @@ static const int IOV_COUNT = 2;
                v->iov_base = msg;
                v->iov_len = strlen(msg);          
 
+writev_retry:
                if ( -1 == writev(remotefd,iov, IOV_COUNT)){
-                       error_msg_and_die("syslogd: cannot write to remote file handle on" 
+                       if (errno == EINTR) goto writev_retry;
+                       error_msg_and_die("syslogd: cannot write to remote file handle on"
                                        "%s:%d",RemoteHost,RemotePort);
                }
        }
-       if (local_logging == TRUE)
+       if (local_logging)
 #endif
                /* now spew out the message to wherever it is supposed to go */
                message("%s %s %s %s\n", timestamp, LocalHostName, res, msg);
@@ -513,13 +521,13 @@ static void doSyslogd (void)
        FD_SET (sock_fd, &fds);
 
 #ifdef CONFIG_FEATURE_IPC_SYSLOG
-       if (circular_logging == TRUE ){
+       if (circular_logging ){
           ipcsyslog_init();
        }
 #endif
 
         #ifdef CONFIG_FEATURE_REMOTE_LOG
-        if (doRemoteLog == TRUE){
+        if (doRemoteLog){
           init_RemoteLog();
         }
         #endif
@@ -583,11 +591,11 @@ extern int syslogd_main(int argc, char **argv)
                                doFork = FALSE;
                                break;
                        case 'O':
-                               logFilePath = strdup(optarg);
+                               logFilePath = xstrdup(optarg);
                                break;
 #ifdef CONFIG_FEATURE_REMOTE_LOG
                        case 'R':
-                               RemoteHost = strdup(optarg);
+                               RemoteHost = xstrdup(optarg);
                                if ( (p = strchr(RemoteHost, ':'))){
                                        RemotePort = atoi(p+1);
                                        *p = '\0';
@@ -610,7 +618,7 @@ extern int syslogd_main(int argc, char **argv)
 
 #ifdef CONFIG_FEATURE_REMOTE_LOG
        /* If they have not specified remote logging, then log locally */
-       if (doRemoteLog == FALSE)
+       if (! doRemoteLog)
                local_logging = TRUE;
 #endif
 
@@ -623,9 +631,13 @@ extern int syslogd_main(int argc, char **argv)
 
        umask(0);
 
-       if (doFork == TRUE) {
+       if (doFork) {
+#if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__)
                if (daemon(0, 1) < 0)
                        perror_msg_and_die("daemon");
+#else
+                       error_msg_and_die("daemon not supported");
+#endif
        }
        doSyslogd();