mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-08-27 04:16:47 +00:00
Merge pull request #17430 from jellyfin/drain-stderr
Drain stderr and stdout concurrently for encoder validation
This commit is contained in:
commit
83e0cfd7ee
1 changed files with 10 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ using System.Linq;
|
|||
using System.Runtime.Versioning;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.MediaEncoding;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
|
@ -662,8 +663,15 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
writer.Write(testKey);
|
||||
}
|
||||
|
||||
using var reader = readStdErr ? process.StandardError : process.StandardOutput;
|
||||
return reader.ReadToEnd();
|
||||
// Drain both streams concurrently to prevent pipe hanging, see #17429
|
||||
using var standardOutput = process.StandardOutput;
|
||||
using var standardError = process.StandardError;
|
||||
var standardOutputTask = standardOutput.ReadToEndAsync();
|
||||
var standardErrorTask = standardError.ReadToEndAsync();
|
||||
process.WaitForExit();
|
||||
Task.WaitAll(standardOutputTask, standardErrorTask);
|
||||
|
||||
return (readStdErr ? standardErrorTask : standardOutputTask).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue