fix QProcess pipe deadlock: drain stdout in run9p while waiting

This commit is contained in:
Levi Neely 2026-08-01 10:38:56 +02:00
parent 95d6da75f6
commit de835e9e6e
1 changed files with 11 additions and 2 deletions

View File

@ -241,6 +241,15 @@ QByteArray Ollie9pClient::run9p(const QStringList &args)
QStringList fullArgs = {"-a", serverAddr()};
fullArgs.append(args);
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;
}