commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1411551 - /commons/proper/daemon/branches/1.0.x/src/native/unix/native/jsvc-unix.c
Date Tue, 20 Nov 2012 05:50:14 GMT
Author: mturk
Date: Tue Nov 20 05:50:13 2012
New Revision: 1411551

URL: http://svn.apache.org/viewvc?rev=1411551&view=rev
Log:
DAEMON-253: Ensure we create pidfile path elements

Modified:
    commons/proper/daemon/branches/1.0.x/src/native/unix/native/jsvc-unix.c

Modified: commons/proper/daemon/branches/1.0.x/src/native/unix/native/jsvc-unix.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/native/unix/native/jsvc-unix.c?rev=1411551&r1=1411550&r2=1411551&view=diff
==============================================================================
--- commons/proper/daemon/branches/1.0.x/src/native/unix/native/jsvc-unix.c (original)
+++ commons/proper/daemon/branches/1.0.x/src/native/unix/native/jsvc-unix.c Tue Nov 20 05:50:13
2012
@@ -501,9 +501,22 @@ static int check_pid(arg_data *args)
     char buff[80];
     pid_t pidn = getpid();
     int i, pid;
+    int once = 0;
 
+retry:
     fd = open(args->pidf, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
     if (fd < 0) {
+        if (once == 0 && (errno == ENOTDIR || errno == ENOENT)) {
+            char *p = strrchr(args->pidf, '/');
+            once = 1;
+            if (p != NULL && *p) {
+               *p = '\0';
+                i = mkdir(args->pidf, S_IRWXU | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH);
+               *p = '/';
+               if (i == 0)
+                   goto retry;
+            }
+        }
         log_error("Cannot open PID file %s, PID is %d", args->pidf, pidn);
         return -1;
     }



Mime
View raw message