m/node/core/time: use CommandContext
Change-Id: Ie98b949facf3d26c819bdf56329f5837b8e3dac7
Reviewed-on: https://review.monogon.dev/c/monogon/+/3712
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/node/core/time/time.go b/metropolis/node/core/time/time.go
index 3e37a0c..bd66e65 100644
--- a/metropolis/node/core/time/time.go
+++ b/metropolis/node/core/time/time.go
@@ -47,7 +47,7 @@
return fmt.Errorf("cannot create fileargs: %w", err)
}
defer args.Close()
- cmd := exec.Command(
+ cmd := exec.CommandContext(ctx,
"/time/chrony",
"-d",
"-i", strconv.Itoa(node.TimeUid),
diff --git a/osbase/supervisor/supervisor_support.go b/osbase/supervisor/supervisor_support.go
index 54d0fd3..c554c08 100644
--- a/osbase/supervisor/supervisor_support.go
+++ b/osbase/supervisor/supervisor_support.go
@@ -63,6 +63,8 @@
// RunCommand will create a Runnable that starts a long-running command, whose
// exit is determined to be a failure.
+// cmd should be created with [exec.CommandContext] so that it will be killed
+// when the context is canceled.
func RunCommand(ctx context.Context, cmd *exec.Cmd, opts ...RunCommandOption) error {
Signal(ctx, SignalHealthy)