* archival/bunzip2.c (bunzip2_main): Do not remove files if writing to standard
[oweals/busybox.git] / sysklogd / syslogd.c
index 236f1190d12e9cb09f78747c2b916469be681311..e1e71378c63a2e78e691fde1fe100fc81f7da21b 100644 (file)
@@ -276,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);
@@ -361,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);
@@ -519,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
@@ -589,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';
@@ -616,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
 
@@ -629,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();