Read stdout to end before waiting for task to end to prevent deadlock

This commit is contained in:
Zorg committed 2016-08-27 09:27:06 -04:00
1 parent 115686cd07
commit f700c96e47
1 file changed
+3 -2
+3 -2
View File
@@ -104,9 +104,10 @@
[inputPipe.fileHandleForWriting writeData:promptData];
[inputPipe.fileHandleForWriting closeFile];
[task waitUntilExit];
// Read data to end *before* waiting until the task ends so we don't deadlock if the stdout buffer becomes full if we haven't consumed from it
output = [outputPipe.fileHandleForReading readDataToEndOfFile];
[task waitUntilExit];
taskResult = task.terminationStatus;
}
@catch (NSException *)