From 2f0ec88e9bf09d32210618f477e5a523d6180dec Mon Sep 17 00:00:00 2001 From: n00mkrad <61149547+n00mkrad@users.noreply.github.com> Date: Tue, 16 Dec 2025 18:34:23 +0100 Subject: [PATCH] (Hopefully) avoid exception when checking if proc has exited (to avoid debugging clutter) --- CodeLegacy/Os/OsUtils.cs | 14 ++++++++++++++ CodeLegacy/Program.cs | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CodeLegacy/Os/OsUtils.cs b/CodeLegacy/Os/OsUtils.cs index 5090a49..dd93768 100644 --- a/CodeLegacy/Os/OsUtils.cs +++ b/CodeLegacy/Os/OsUtils.cs @@ -333,5 +333,19 @@ namespace Flowframes.Os return string.Join(";", newPaths.Select(x => x.Replace("\\", "/"))) + ";"; } + + public static bool IsStillRunning(Func proc) // For .NET Core migration: Func (nullable) + { + var p = proc(); // Snapshot of the process to avoid race condition + + try + { + return p is null || !p.HasExited; + } + catch + { + return false; + } + } } } \ No newline at end of file diff --git a/CodeLegacy/Program.cs b/CodeLegacy/Program.cs index f686538..42b851d 100644 --- a/CodeLegacy/Program.cs +++ b/CodeLegacy/Program.cs @@ -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) {