OSSP CVS Repository

ossp - Check-in [3347]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3347
Date: 2003-May-19 21:04:22 (local)
2003-May-19 19:04:22 (UTC)
User:ms
Branch:
Comment: Extend priority scheduling feature to --exec mode block.
Tickets:
Inspections:
Files:
ossp-pkg/rc/rc_proc.c      1.24 -> 1.25     23 inserted, 7 deleted

ossp-pkg/rc/rc_proc.c 1.24 -> 1.25

--- rc_proc.c    2003/05/16 18:43:30     1.24
+++ rc_proc.c    2003/05/19 19:04:22     1.25
@@ -36,6 +36,7 @@
 #include <sys/stat.h>
 
 #include "rc.h"         /* Public interfaces        */
+#include "rc_const.h"   /* String and value const   */
 #include "rc_config.h"  /* Option definitions       */
 
 
@@ -196,6 +197,11 @@
     int   nTotsecs = pRc->m_pAnal->m_nRcs * pRc->m_pAnal->m_nSecs;
     char *pszVec[RC_EXEC_MAXARGS];
 
+    /* Conditionally sort the section vector according to explicit priority */
+    if (!strcmp(configGetrcfile(), RC_GLOB_WILD)) {
+        qsort((void *)pRc->m_ppSectvec, (size_t)nTotsecs, sizeof (rc_section_t *), priCompare);
+    }
+
     /****************************************************/
     /* This will execute, evaluate, or print the script */
     /* Exec  - Fork and execute each command            */
@@ -205,15 +211,25 @@
     if (configGetval(RC_EVL_VAL))                              /* Evaluate */
         fprintf(stderr, "Error: Evaluate is not implemented yet.\n"); /* FIX */
     else if (configGetval(RC_EXC_VAL)) {                       /* Execute  */
-            pszVec[0] = "/bin/sh";
-            pszVec[1] = "-c";
-            pszVec[2] = (char *)scriptTostring(pRc->m_pScriptcom);
-            pszVec[3] = NULL;   /* Add a NULL to mark the end of the chain */
-        if (execvp(*pszVec, pszVec) == -1)                       /* launch */
-            TRACE("Bad, execvp in child returned -1");
+        pszVec[0] = "/bin/sh";
+        pszVec[1] = "-c";
+        pszVec[2] = (char *)scriptTostring(pRc->m_pScriptcom);
+        pszVec[3] = NULL;   /* Add a NULL to mark the end of the chain */
+        if (execvp(*pszVec, pszVec) == -1) {                     /* launch */
+            TRACE("Bad, execvp for common script in child returned -1");
+            return(RC_THROW(RC_ERR_INT));
+        }
+        for (nIter = 0; nIter < nTotsecs; nIter++) {
+            if (pRc->m_ppSectvec[nIter]) {
+                pszVec[2] = (char *)sectionGetdata(pRc->m_ppSectvec[nIter]);
+                if (execvp(*pszVec, pszVec) == -1) {             /* launch */
+                    TRACE("Bad, execvp for subsection in child returned -1");
+                    return(RC_THROW(RC_ERR_INT));
+                }
+            }
+        }
     }
     else if (configGetval(RC_PRN_VAL)) {                         /* Print  */
-        qsort((void *)pRc->m_ppSectvec, (size_t)nTotsecs, sizeof (rc_section_t *), priCompare);
         scriptDump(pRc->m_pScriptcom);
         for (nIter = 0; nIter < nTotsecs; nIter++) {
             if (pRc->m_ppSectvec[nIter])

CVSTrac 2.0.1