fix QProcess pipe deadlock: drain stdout in run9p while waiting
This commit is contained in:
parent
95d6da75f6
commit
de835e9e6e
|
|
@ -241,6 +241,15 @@ QByteArray Ollie9pClient::run9p(const QStringList &args)
|
||||||
QStringList fullArgs = {"-a", serverAddr()};
|
QStringList fullArgs = {"-a", serverAddr()};
|
||||||
fullArgs.append(args);
|
fullArgs.append(args);
|
||||||
proc.start(ninepBin(), fullArgs);
|
proc.start(ninepBin(), fullArgs);
|
||||||
proc.waitForFinished(10000);
|
|
||||||
return proc.readAllStandardOutput();
|
// Drain output while waiting. The log file can be up to 64KB; if the
|
||||||
|
// parent doesn't read, the child blocks on a full pipe and never exits,
|
||||||
|
// causing "QProcess: Destroyed while process is still running".
|
||||||
|
QByteArray out;
|
||||||
|
while (proc.state() != QProcess::NotRunning) {
|
||||||
|
if (proc.waitForReadyRead(100))
|
||||||
|
out += proc.readAllStandardOutput();
|
||||||
|
}
|
||||||
|
out += proc.readAllStandardOutput();
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in New Issue