in startProcess use _exit instead of exit after fork in child; test command with...
[libasyncio] / asyncio / async_process.cpp
index 5169b5c..f93e320 100644 (file)
@@ -445,6 +445,14 @@ bool ProcessImplementation::startProcess( IOImplementation2 *stderr )
       // process still/already running...
       return false;
    }
+
+   Utils::FileStat stat(m_path);
+   if (! stat.is_exec_file())
+   {
+       // command to execute does not exist or is not executable
+       return false;
+   }
+
    m_exit_code= 0;
 
    if (stderr == _StderrOnStdout)
@@ -540,7 +548,7 @@ bool ProcessImplementation::startProcess( IOImplementation2 *stderr )
          if (r !=0 )
          {
             //TODO?
-            exit(255);
+            _exit(255);
          }
       }
 
@@ -568,9 +576,11 @@ bool ProcessImplementation::startProcess( IOImplementation2 *stderr )
       // execute:
       execv(m_path.c_str(), argv);
       // exit if exec failed
-      exit(255);
+      _exit(255);
       //cleanup! ... just joking; we exec or we exit, in either case the system cleans
       // everything which needs to be cleaned up.
+      // Using _exit instead of exit, it will not clean up the clone of parent's memory
+      //   in case of failure to exec m_path
    }
    return false; // keep the compiler happy...
 } // eo ProcessImplementation::startProcess()