From ac3e6d92dad5f788de16e3cab8a93853d76459e1 Mon Sep 17 00:00:00 2001 From: Hideaki Murakami Date: Fri, 6 Mar 2026 13:40:40 +1300 Subject: [PATCH 1/2] Add stuck process detection --- .../Util/CommandLine/SilentProcessRunner.cs | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/source/Octopus.Tentacle.Core/Util/CommandLine/SilentProcessRunner.cs b/source/Octopus.Tentacle.Core/Util/CommandLine/SilentProcessRunner.cs index db362ef0b..c40786173 100644 --- a/source/Octopus.Tentacle.Core/Util/CommandLine/SilentProcessRunner.cs +++ b/source/Octopus.Tentacle.Core/Util/CommandLine/SilentProcessRunner.cs @@ -140,7 +140,35 @@ void WriteData(Action action, ManualResetEventSlim resetEvent, DataRecei process.BeginOutputReadLine(); process.BeginErrorReadLine(); - process.WaitForExit(); + var lastMemoryUsage = process.WorkingSet64; + var lastTotalProcessorTime = process.TotalProcessorTime; + var lastStuckProcessorTime = process.TotalProcessorTime; + try + { + while (!process.WaitForExit(1000)) + { + if (process.HasExited) break; + process.Refresh(); + if (lastTotalProcessorTime == process.TotalProcessorTime && lastMemoryUsage == process.WorkingSet64 && lastStuckProcessorTime != process.TotalProcessorTime) + { + debug("Tentacle has detected a potential stuck process."); + lastStuckProcessorTime = process.TotalProcessorTime; + } + lastTotalProcessorTime = process.TotalProcessorTime; + lastMemoryUsage = process.WorkingSet64; + } + } + catch (Exception e) + { + try + { + error($"Error occured while executing {executable}: {e.PrettyPrint()}"); + } + catch + { + // Ignore + } + } SafelyCancelRead(process.CancelErrorRead, debug); SafelyCancelRead(process.CancelOutputRead, debug); From 25189dec83120ba5731b10f5008b9a17ccdf4c47 Mon Sep 17 00:00:00 2001 From: Hideaki Murakami Date: Fri, 6 Mar 2026 16:03:36 +1300 Subject: [PATCH 2/2] Try reducing exception handling --- .../Util/CommandLine/SilentProcessRunner.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/Octopus.Tentacle.Core/Util/CommandLine/SilentProcessRunner.cs b/source/Octopus.Tentacle.Core/Util/CommandLine/SilentProcessRunner.cs index c40786173..ed0fce1dc 100644 --- a/source/Octopus.Tentacle.Core/Util/CommandLine/SilentProcessRunner.cs +++ b/source/Octopus.Tentacle.Core/Util/CommandLine/SilentProcessRunner.cs @@ -151,18 +151,18 @@ void WriteData(Action action, ManualResetEventSlim resetEvent, DataRecei process.Refresh(); if (lastTotalProcessorTime == process.TotalProcessorTime && lastMemoryUsage == process.WorkingSet64 && lastStuckProcessorTime != process.TotalProcessorTime) { - debug("Tentacle has detected a potential stuck process."); + //debug("Tentacle has detected a potential stuck process."); lastStuckProcessorTime = process.TotalProcessorTime; } lastTotalProcessorTime = process.TotalProcessorTime; lastMemoryUsage = process.WorkingSet64; } } - catch (Exception e) + catch (SystemException) { try { - error($"Error occured while executing {executable}: {e.PrettyPrint()}"); + //error($"Error occured while executing {executable}: {e.PrettyPrint()}"); } catch {