From 1dec98d2fcfc1a7774717dbde7e97d2ba08b938e Mon Sep 17 00:00:00 2001 From: Daniel Rebelsky <4641927+drebelsky@users.noreply.github.com> Date: Tue, 28 Apr 2026 14:21:59 -0700 Subject: [PATCH] Swallow SIGINT while running kubectl --- src/FSLibrary/StellarSupercluster.fs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/FSLibrary/StellarSupercluster.fs b/src/FSLibrary/StellarSupercluster.fs index c48eba8e..358bd028 100644 --- a/src/FSLibrary/StellarSupercluster.fs +++ b/src/FSLibrary/StellarSupercluster.fs @@ -62,11 +62,20 @@ let ConnectToCluster (cfgFile: string) (nsOpt: string option) : (Kubernetes * st with :? ComponentModel.Win32Exception -> false if started then - if proc.WaitForExit(TimeSpan(0, 1, 0)) then - if proc.ExitCode = 0 then RanSuccess else RanWithError proc.ExitCode - else - proc.Kill() - DidNotComplete(proc.WaitForExit(TimeSpan(0, 1, 0))) + // Swallow Ctrl+C in the parent while kubectl is running, so the + // SIGINT delivered to the foreground process group only stops + // kubectl and lets us decide what to do next. + let cancelHandler = ConsoleCancelEventHandler(fun _ e -> e.Cancel <- true) + Console.CancelKeyPress.AddHandler cancelHandler + + try + if proc.WaitForExit(TimeSpan(0, 1, 0)) then + if proc.ExitCode = 0 then RanSuccess else RanWithError proc.ExitCode + else + proc.Kill() + DidNotComplete(proc.WaitForExit(TimeSpan(0, 1, 0))) + finally + Console.CancelKeyPress.RemoveHandler cancelHandler else DidNotRun)