Skip to content

Commit 8d01c44

Browse files
committed
Increase subprocess stream reading reliability
1 parent 10df75f commit 8d01c44

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/util/subprocess.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace linuxdeploy {
1919
fcntl(fileno(fd), F_SETFL, flags);
2020
}
2121

22-
do {
22+
while (true) {
2323
constexpr auto bufSize = 1;
2424
// constexpr auto bufSize = 512*1024;
2525
std::vector<char> buf(bufSize, '\0');
@@ -42,7 +42,10 @@ namespace linuxdeploy {
4242
outBuf.reserve(outBufSize + size + 1);
4343
std::copy(buf.begin(), buf.begin() + size, std::back_inserter(outBuf));
4444
}
45-
} while (proc.poll() < 0);
45+
46+
if (proc.poll() >= 0 && feof(proc.output()) != 0 && feof(proc.error()) != 0)
47+
break;
48+
}
4649

4750
std::string stdoutContents(procStdout.begin(), procStdout.end());
4851
std::string stderrContents(procStderr.begin(), procStderr.end());

0 commit comments

Comments
 (0)