Prevent main-process crash when render worker dies during IPC write
When a render-worker process crashed or exited while the worker-pool thread was writing a control message (e.g. right after an audio-sync and drag operation triggered a new render), the main process received SIGPIPE and terminated at WriteControlMessage(). - Ignore SIGPIPE in main() so QProcess can report the broken pipe through its normal error path instead of killing the application. - Harden WriteControlMessage() / TryWriteControlMessage() to check the process state and the number of bytes written before waiting.
This commit is contained in:
@@ -267,12 +267,24 @@ QString WorkerProgramPath()
|
||||
|
||||
bool WriteControlMessage(QProcess *process, const QJsonObject &obj)
|
||||
{
|
||||
if (!process || process->state() != QProcess::Running) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const QByteArray line = QJsonDocument(obj).toJson(QJsonDocument::Compact) + '\n';
|
||||
return process->write(line) == line.size() && process->waitForBytesWritten(5000);
|
||||
const qint64 written = process->write(line);
|
||||
if (written != line.size()) {
|
||||
return false;
|
||||
}
|
||||
return process->waitForBytesWritten(5000);
|
||||
}
|
||||
|
||||
void TryWriteControlMessage(QProcess *process, const QJsonObject &obj)
|
||||
{
|
||||
if (!process || process->state() != QProcess::Running) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QByteArray line = QJsonDocument(obj).toJson(QJsonDocument::Compact) + '\n';
|
||||
process->write(line);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user