mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(cli): cancel the run context on SIGINT so spawned children are reaped
This commit is contained in:
1 parent
f1a6adf2d4
commit
bbab168b8e
1 file changed
+7
-1
@@ -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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user