mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-08-04 07:10:45 +00:00
fix: accessing Standard* of a Process requires manually disposing them afterwards (#10125)
This commit is contained in:
parent
260680d727
commit
956e3dab43
6 changed files with 56 additions and 48 deletions
|
|
@ -553,7 +553,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
|
||||
private string GetProcessOutput(string path, string arguments, bool readStdErr, string? testKey)
|
||||
{
|
||||
using (var process = new Process()
|
||||
var redirectStandardIn = !string.IsNullOrEmpty(testKey);
|
||||
using (var process = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo(path, arguments)
|
||||
{
|
||||
|
|
@ -561,7 +562,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
UseShellExecute = false,
|
||||
WindowStyle = ProcessWindowStyle.Hidden,
|
||||
ErrorDialog = false,
|
||||
RedirectStandardInput = !string.IsNullOrEmpty(testKey),
|
||||
RedirectStandardInput = redirectStandardIn,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true
|
||||
}
|
||||
|
|
@ -571,12 +572,14 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
|
||||
process.Start();
|
||||
|
||||
if (!string.IsNullOrEmpty(testKey))
|
||||
if (redirectStandardIn)
|
||||
{
|
||||
process.StandardInput.Write(testKey);
|
||||
using var writer = process.StandardInput;
|
||||
writer.Write(testKey);
|
||||
}
|
||||
|
||||
return readStdErr ? process.StandardError.ReadToEnd() : process.StandardOutput.ReadToEnd();
|
||||
using var reader = readStdErr ? process.StandardError : process.StandardOutput;
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue