File 0002-Fixed-2744-create-run-directory-if-it-does-not-exist.patch of Package sblim-gather

From 506e4567a3ee40d313525a09e67f1a294aedd368 Mon Sep 17 00:00:00 2001
From: Dave Heller <hellerda@us.ibm.com>
Date: Fri, 21 Aug 2015 11:42:58 -0400
Subject: [PATCH 2/3] Fixed #2744: create run directory if it does not exist

---
 ChangeLog           |  3 +++
 NEWS                |  1 +
 comms/mcserv_unix.c | 11 +++++++++++
 3 files changed, 15 insertions(+)

diff --git a/comms/mcserv_unix.c b/comms/mcserv_unix.c
index 65958f0ff473..2ba7ed30d1bd 100644
--- a/comms/mcserv_unix.c
+++ b/comms/mcserv_unix.c
@@ -25,6 +25,7 @@
 #include <sys/un.h>
 #include <sys/file.h>
 #include <sys/poll.h>
+#include <sys/stat.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -50,6 +51,7 @@ int mcs_init(const char *commid)
 {
   struct sockaddr_un sa;
   struct sigaction sigact;
+  struct stat buf;
 
   if (commhandle==-1) {
     commhandle=socket(PF_UNIX,SOCK_STREAM,0);
@@ -59,6 +61,15 @@ int mcs_init(const char *commid)
 	    strerror(errno));
       return -1;
     }
+    if (stat(GATHER_RUNDIR, &buf) || !(buf.st_mode & S_IFDIR)) {
+      if (mkdir(GATHER_RUNDIR, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)) {
+        m_log(M_ERROR,M_SHOW,
+              "mcs_init: could not create run directory %s: %s\n",
+              GATHER_RUNDIR,
+              strerror(errno));
+        return -1;
+      }
+    }
     if (fdlockfile == -1) {
       if (snprintf(lockname,PATH_MAX+2,MC_LOCKFILE,commid) > 
 	  PATH_MAX) {
-- 
2.15.0

openSUSE Build Service is sponsored by