Browse Source

KWSys: Teach Process to error on empty command

Do not try to execute a child with no command line.  Previously this led
to a silent hang.
Brad King 15 years ago
parent
commit
b9e3c243d4
2 changed files with 16 additions and 0 deletions
  1. 8 0
      Source/kwsys/ProcessUNIX.c
  2. 8 0
      Source/kwsys/ProcessWin32.c

+ 8 - 0
Source/kwsys/ProcessUNIX.c

@@ -720,6 +720,14 @@ void kwsysProcess_Execute(kwsysProcess* cp)
     return;
     return;
     }
     }
 
 
+  /* Make sure we have something to run.  */
+  if(cp->NumberOfCommands < 1)
+    {
+    strcpy(cp->ErrorMessage, "No command");
+    cp->State = kwsysProcess_State_Error;
+    return;
+    }
+
   /* Initialize the control structure for a new process.  */
   /* Initialize the control structure for a new process.  */
   if(!kwsysProcessInitialize(cp))
   if(!kwsysProcessInitialize(cp))
     {
     {

+ 8 - 0
Source/kwsys/ProcessWin32.c

@@ -987,6 +987,14 @@ void kwsysProcess_Execute(kwsysProcess* cp)
     return;
     return;
     }
     }
 
 
+  /* Make sure we have something to run.  */
+  if(cp->NumberOfCommands < 1)
+    {
+    strcpy(cp->ErrorMessage, "No command");
+    cp->State = kwsysProcess_State_Error;
+    return;
+    }
+
   /* Initialize the control structure for a new process.  */
   /* Initialize the control structure for a new process.  */
   if(!kwsysProcessInitialize(cp))
   if(!kwsysProcessInitialize(cp))
     {
     {