Browse Source

Fix process errors on platforms not supporting some process name and duration reports

pull/283/head
Ionite 1 year ago
parent
commit
39735155b2
No known key found for this signature in database
  1. 20
      StabilityMatrix.Core/Processes/ProcessRunner.cs

20
StabilityMatrix.Core/Processes/ProcessRunner.cs

@ -204,13 +204,29 @@ public static class ProcessRunner
await process.WaitForExitAsync().ConfigureAwait(false); 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 return new ProcessResult
{ {
ExitCode = process.ExitCode, ExitCode = process.ExitCode,
StandardOutput = stdout, StandardOutput = stdout,
StandardError = stderr, StandardError = stderr,
ProcessName = process.MachineName, ProcessName = processName,
Elapsed = process.ExitTime - process.StartTime Elapsed = elapsed
}; };
} }

Loading…
Cancel
Save