]> andersk Git - moira.git/blobdiff - update/exec_002.c
added hosttable stuff
[moira.git] / update / exec_002.c
index eea177351fc43a08e4f4ac2363096fedd537292e..03188efcd65ea1a2172aa9029a02d2dae947f93a 100644 (file)
@@ -14,7 +14,13 @@ static char *rcsid_exec_002_c = "$Header$";
 #include <stdio.h>
 #include <errno.h>
 #include <sys/types.h>
+#ifdef _AIX
+#undef _BSD
+#endif
 #include <sys/wait.h>
+#ifdef _AIX
+#define _BSD 44
+#endif
 #include <signal.h>
 #include <gdb.h>
 #include <moira.h>
@@ -33,12 +39,14 @@ int
 exec_002(str)
     char *str;
 {
-#ifdef _AIX
+#ifdef POSIX
     int waitb;
+    sigset_t mask,oldmask;
 #else
     union wait waitb;
+    int mask;
 #endif
-    int n, pid, mask;
+    int n, pid;
 
     if (config_lookup("noexec")) {
        code = EPERM;
@@ -49,12 +57,22 @@ exec_002(str)
     str += 8;
     while (*str == ' ')
        str++;
+#ifdef POSIX
+    sigemptyset(&mask);
+    sigaddset(&mask,SIGCHLD);
+    sigprocmask(SIG_BLOCK,&mask,&oldmask);
+#else
     mask = sigblock(sigmask(SIGCHLD));
+#endif
     pid = fork();
     switch (pid) {
     case -1:
        n = errno;
+#ifdef POSIX
+       sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
+#else
        sigsetmask(mask);
+#endif
        log_priority = log_ERROR;
        com_err(whoami, errno, ": can't fork to run install script");
        code = send_object(conn, (char *)&n, INTEGER_T);
@@ -66,10 +84,18 @@ exec_002(str)
            com_err(whoami, errno, "Unable to setuid to %d\n", uid);
            exit(1);
        }
+#ifdef POSIX
+       sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
+#else
        sigsetmask(mask);
+#endif
        execlp(str, str, (char *)NULL);
        n = errno;
+#ifdef POSIX
+       sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
+#else
        sigsetmask(mask);
+#endif
        log_priority = log_ERROR;
        com_err(whoami, n, ": %s", str);
        (void) send_object(conn, (char *)&n, INTEGER_T);
@@ -78,12 +104,24 @@ exec_002(str)
        do {
            n = wait(&waitb);
        } while (n != -1 && n != pid);
+#ifdef POSIX
+       sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
+#else
        sigsetmask(mask);
-       if (WEXITSTATUS(waitb)) {
+#endif
+#ifdef POSIX
+       if (WIFEXITED(waitb)) {
            n = WEXITSTATUS(waitb) + ERROR_TABLE_BASE_sms;
            log_priority = log_ERROR;
            com_err(whoami, n, " child exited with status %d",
                    WEXITSTATUS(waitb));
+#else
+       if (waitb.w_status) {
+           n = waitb.w_retcode + ERROR_TABLE_BASE_sms;
+           log_priority = log_ERROR;
+           com_err(whoami, n, " child exited with status %d",
+                   waitb.w_retcode);
+#endif
            code = send_object(conn, (char *)&n, INTEGER_T);
            if (code) {
                exit(1);
This page took 0.224599 seconds and 4 git commands to generate.