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);
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
};
}

Loading…
Cancel
Save