From: <bi...@us...> - 2018-04-13 11:09:39
|
Revision: 11426 http://sourceforge.net/p/oorexx/code-0/11426 Author: bigrixx Date: 2018-04-13 11:09:37 +0000 (Fri, 13 Apr 2018) Log Message: ----------- read the output pipes before waiting for the process to terminate Modified Paths: -------------- sandbox/rick/addresswith/interpreter/platform/windows/SystemCommands.cpp Modified: sandbox/rick/addresswith/interpreter/platform/windows/SystemCommands.cpp =================================================================== --- sandbox/rick/addresswith/interpreter/platform/windows/SystemCommands.cpp 2018-04-13 10:53:02 UTC (rev 11425) +++ sandbox/rick/addresswith/interpreter/platform/windows/SystemCommands.cpp 2018-04-13 11:09:37 UTC (rev 11426) @@ -410,6 +410,48 @@ { SetConsoleTitle(siStartInfo.lpTitle); } + + + // if Output is redirected, write the data from the output pipe + if (redirOut) + { + CloseHandle(siStartInfo.hStdOutput); // close the handle so readFile will stop + for (;;) + { + readOK = ReadFile(outPipeR, pipeBuf, READ_SIZE, &cntRead, NULL); + if (!readOK || cntRead == 0) + { + break; + } + ioContext->WriteOutputBuffer(pipeBuf, cntRead); + } + } + + // if Error is redirected, write the data from the error pipe + if (redirErr) + { + CloseHandle(siStartInfo.hStdError); // close the handle so readPipe will stop + for (;;) + { + readOK = ReadFile(errPipeR, pipeBuf, READ_SIZE, &cntRead, NULL); + if (!readOK || cntRead == 0) + { + break; + } + ioContext->WriteErrorBuffer(pipeBuf, cntRead); + } + } + + // do we have input cleanup to perform? + if (redirIn) + { + // make sure the thread is really terminated + inputThread.terminate(); + // give the input thead a chance to raise an error too. + inputThread.handleError(context); + } + + SystemInterpreter::exceptionHostProcess = piProcInfo.hProcess; SystemInterpreter::exceptionHostProcessId = piProcInfo.dwProcessId; @@ -434,35 +476,6 @@ } CloseHandle(piProcInfo.hThread); CloseHandle(piProcInfo.hProcess); - - // if Output is redirected, write the data from the output pipe - if (redirOut) { - CloseHandle(siStartInfo.hStdOutput); // close the handle so readFile will stop - for (;;) { - readOK = ReadFile(outPipeR, pipeBuf, READ_SIZE, &cntRead, NULL); - if (!readOK || cntRead == 0) break; - ioContext->WriteOutputBuffer(pipeBuf, cntRead); - } - } - - // if Error is redirected, write the data from the error pipe - if (redirErr) { - CloseHandle(siStartInfo.hStdError); // close the handle so readPipe will stop - for (;;) { - readOK = ReadFile(errPipeR, pipeBuf, READ_SIZE, &cntRead, NULL); - if (!readOK || cntRead == 0) break; - ioContext->WriteErrorBuffer(pipeBuf, cntRead); - } - } - - // do we have input cleanup to perform? - if (redirIn) - { - // make sure the thread is really terminated - inputThread.terminate(); - // give the input thead a chance to raise an error too. - inputThread.handleError(context); - } } else { |