(Hopefully) avoid exception when checking if proc has exited (to avoid debugging clutter)

This commit is contained in:
n00mkrad
2025-12-16 18:34:23 +01:00
parent 90c8491cf2
commit 2f0ec88e9b
2 changed files with 15 additions and 1 deletions

View File

@@ -333,5 +333,19 @@ namespace Flowframes.Os
return string.Join(";", newPaths.Select(x => x.Replace("\\", "/"))) + ";";
}
public static bool IsStillRunning(Func<Process> proc) // For .NET Core migration: Func<Process?> (nullable)
{
var p = proc(); // Snapshot of the process to avoid race condition
try
{
return p is null || !p.HasExited;
}
catch
{
return false;
}
}
}
}

View File

@@ -182,7 +182,7 @@ namespace Flowframes
// Logger.Log($"Disk space check for '{drivePath}/': {spaceGb} GB free, next check in {nextWaitTimeMs / 1024} sec", true);
if (!Interpolate.canceled && (AiProcess.lastAiProcess != null && !AiProcess.lastAiProcess.HasExited) && lowDiskSpace)
if (!Interpolate.canceled && OsUtils.IsStillRunning(() => AiProcess.lastAiProcess) && lowDiskSpace)
{
if (tooLowDiskSpace)
{