diff options
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src/Process.cpp')
-rw-r--r-- | Build/source/texk/dvisvgm/dvisvgm-src/src/Process.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Process.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/Process.cpp index 238bacb2373..adb364855a4 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Process.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Process.cpp @@ -76,8 +76,10 @@ bool Process::run (string *out) { if (!subprocess.run(_cmd, _paramstr)) return false; for (;;) { - if (out) + if (out) { + out->clear(); subprocess.readFromPipe(*out); + } Subprocess::State state = subprocess.state(); if (state != Subprocess::State::RUNNING) return state == Subprocess::State::FINISHED; @@ -133,12 +135,22 @@ bool Subprocess::readFromPipe (string &out) { return false; bool success=false; - DWORD len; - while (PeekNamedPipe(_pipeReadHandle, NULL, 0, NULL, &len, NULL) && len > 0) { // prevent blocking - char buf[4096]; - success = ReadFile(_pipeReadHandle, buf, sizeof(buf), &len, NULL); - if (success && len > 0) + bool processExited=false; + DWORD len=0; + while (PeekNamedPipe(_pipeReadHandle, NULL, 0, NULL, &len, NULL)) { // prevent blocking + if (len == 0) { + if (processExited) + break; + // process still busy + processExited = (!_childProcHandle || WaitForSingleObject(_childProcHandle, 100) != WAIT_TIMEOUT); + } + else { + char buf[4096]; + success = ReadFile(_pipeReadHandle, buf, sizeof(buf), &len, NULL); + if (!success || len == 0) + break; out.append(buf, len); + } } return success; } |