Przeglądaj źródła

Merge pull request #12801 from jakesmith/hpcc-22554

HPCC-22554 pipe->run would stall if it's thread failed to create handles

Reviewed-By: Mark Kelly <mark.kelly@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 5 lat temu
rodzic
commit
2ea3b7b88e
1 zmienionych plików z 8 dodań i 9 usunięć
  1. 8 9
      system/jlib/jthread.cpp

+ 8 - 9
system/jlib/jthread.cpp

@@ -1954,15 +1954,14 @@ public:
         int inpipe[2];
         int outpipe[2];
         int errpipe[2];
-        if (hasinput)
-            if (::pipe(inpipe)==-1)
-                throw makeOsException(errno);
-        if (hasoutput)
-            if (::pipe(outpipe)==-1)
-                throw makeOsException(errno);
-        if (haserror)
-            if (::pipe(errpipe)==-1)
-                throw makeOsException(errno);
+        if ((hasinput && (::pipe(inpipe)==-1)) ||
+            (hasoutput && (::pipe(outpipe)==-1)) ||
+            (haserror && (::pipe(errpipe)==-1)))
+        {
+            retcode = START_FAILURE;
+            started.signal();
+            throw makeOsException(errno);
+        }
 
         /* NB: Important to call splitargs (which calls malloc) before the fork()
          * and not in the child process. Because performing malloc in the child