diff --git a/src/Tgstation.Server.Host/System/ProcessExecutor.cs b/src/Tgstation.Server.Host/System/ProcessExecutor.cs index 1e5ea2e45a..874fd461c9 100644 --- a/src/Tgstation.Server.Host/System/ProcessExecutor.cs +++ b/src/Tgstation.Server.Host/System/ProcessExecutor.cs @@ -109,14 +109,14 @@ namespace Tgstation.Server.Host.System handle.StartInfo.UseShellExecute = !noShellExecute; - var processStartTcs = new TaskCompletionSource(); - Task readTask = null; CancellationTokenSource disposeCts = null; try { + TaskCompletionSource processStartTcs = null; if (readStandardHandles) { + processStartTcs = new TaskCompletionSource(); handle.StartInfo.RedirectStandardOutput = true; handle.StartInfo.RedirectStandardError = true; @@ -128,11 +128,11 @@ namespace Tgstation.Server.Host.System { handle.Start(); - processStartTcs.SetResult(); + processStartTcs?.SetResult(); } catch (Exception ex) { - processStartTcs.SetException(ex); + processStartTcs?.SetException(ex); throw; }