From 9fcc3c53fcb301b04d4627abf3edef4bf137cec3 Mon Sep 17 00:00:00 2001
From: chylex <contact@chylex.com>
Date: Sat, 30 Mar 2024 07:05:59 +0100
Subject: [PATCH] Catch "The pipe is being closed" Windows exception when
 stopping instance

---
 .../Instances/State/InstanceStopProcedure.cs                    | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Agent/Phantom.Agent.Services/Instances/State/InstanceStopProcedure.cs b/Agent/Phantom.Agent.Services/Instances/State/InstanceStopProcedure.cs
index 6c43968..560e454 100644
--- a/Agent/Phantom.Agent.Services/Instances/State/InstanceStopProcedure.cs
+++ b/Agent/Phantom.Agent.Services/Instances/State/InstanceStopProcedure.cs
@@ -75,6 +75,8 @@ static class InstanceStopProcedure {
 			// Ignore.
 		} catch (ObjectDisposedException e) when (e.ObjectName == typeof(Process).FullName && process.HasEnded) {
 			// Ignore.
+		} catch (IOException e) when (e.HResult == -2147024664 /* The pipe is being closed */) {
+			// Ignore.
 		} catch (Exception e) {
 			context.Logger.Warning(e, "Caught exception while sending stop command.");
 		}