diff --git a/StabilityMatrix.Core/Processes/ProcessRunner.cs b/StabilityMatrix.Core/Processes/ProcessRunner.cs index 4eb56a0a..74b906bc 100644 --- a/StabilityMatrix.Core/Processes/ProcessRunner.cs +++ b/StabilityMatrix.Core/Processes/ProcessRunner.cs @@ -204,13 +204,29 @@ public static class ProcessRunner await process.WaitForExitAsync().ConfigureAwait(false); + string? processName = null; + TimeSpan elapsed = default; + + // Accessing these properties may throw an exception if the process has already exited + try + { + processName = process.ProcessName; + } + catch (SystemException) { } + + try + { + elapsed = process.ExitTime - process.StartTime; + } + catch (SystemException) { } + return new ProcessResult { ExitCode = process.ExitCode, StandardOutput = stdout, StandardError = stderr, - ProcessName = process.MachineName, - Elapsed = process.ExitTime - process.StartTime + ProcessName = processName, + Elapsed = elapsed }; }