]> git.pld-linux.org Git - projects/rc-scripts.git/blobdiff - src/initlog.c
netfs: respect VSERVER_ISOLATION_NET here as well
[projects/rc-scripts.git] / src / initlog.c
index 7409edb9a4d023d35e739524bca7e91be46f5922..3b1cded633749466474784beab38cf2da6c0e29e 100644 (file)
@@ -168,6 +168,38 @@ char **toArray(char *line, int *num) {
     return lines;
 }
 
+int startDaemon() {
+    int pid;
+    int rc;
+    
+    if ( (pid = fork()) == -1 ) {
+       perror("fork");
+       return -1;
+    }
+    if ( pid ) {
+       /* parent */
+       waitpid(pid,&rc,0);
+       if (WIFEXITED(rc)) {
+         DDEBUG("minilogd returned %d!\n",WEXITSTATUS(rc));
+         return WEXITSTATUS(rc);
+       }
+       else
+         return -1;
+    } else {
+       int fd;
+       
+       fd=open("/dev/null",O_RDWR);
+       dup2(fd,0);
+       dup2(fd,1);
+       dup2(fd,2);
+        close(fd);
+       /* kid */
+       execlp("minilogd","minilogd",NULL);
+       perror("exec");
+       exit(-1);
+    }
+}
+
 int trySocket() {
        int s;
        struct sockaddr_un addr;
@@ -181,7 +213,7 @@ int trySocket() {
        strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1);
 
        if (connect(s,(struct sockaddr *) &addr,sizeof(addr))<0) {
-               if (errno == EPROTOTYPE) {
+               if (errno == EPROTOTYPE || errno == ECONNREFUSED) {
                        DDEBUG("connect failed (EPROTOTYPE), trying stream\n");
                        close(s);
                        s = socket(AF_LOCAL, SOCK_STREAM, 0);
@@ -212,6 +244,7 @@ int logLine(struct logInfo *logEnt) {
     
        
     if  ( ((stat(_PATH_LOG,&statbuf)==-1) || trySocket())
+         && startDaemon()
        ) {
        DDEBUG("starting daemon failed, pooling entry %d\n",logEntries);
        logData=realloc(logData,(logEntries+1)*sizeof(struct logInfo));
This page took 0.032593 seconds and 4 git commands to generate.