From bbab168b8e3d79e3ac501630b1db3ffe09f6923a Mon Sep 17 00:00:00 2001 From: PJ Date: Sun, 7 Jun 2026 21:38:18 +0530 Subject: [PATCH] fix(cli): cancel the run context on SIGINT so spawned children are reaped --- cmd/sanderling/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/sanderling/main.go b/cmd/sanderling/main.go index ed7cc36..16b0088 100644 --- a/cmd/sanderling/main.go +++ b/cmd/sanderling/main.go @@ -8,6 +8,8 @@ import ( "fmt" "io" "os" + "os/signal" + "syscall" "time" ) @@ -74,7 +76,11 @@ func parseTestArgs(args []string, stderr io.Writer) (testOptions, error) { } func runTest(options testOptions, stdout io.Writer) error { - ctx, cancel := context.WithCancel(context.Background()) + // A signal-aware root context: on Ctrl-C the cancellation propagates into + // the drivers' process contexts, so spawned children (the iOS companion, + // the xcodebuild runner session) get their SIGTERM instead of outliving + // the run as orphans. + ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) defer cancel() return runTestPipeline(ctx, options, stdout) }