@@ -167,7 +167,7 @@ func dockerCmd() *cobra.Command {
167
167
)
168
168
169
169
// We technically leak a context here, but it's impact is negligible.
170
- signalCtx , signalCancel := context .WithCancel (cmd . Context () )
170
+ signalCtx , signalCancel := context .WithCancel (ctx )
171
171
sigs := make (chan os.Signal , 1 )
172
172
signal .Notify (sigs , syscall .SIGTERM , syscall .SIGINT , syscall .SIGWINCH )
173
173
@@ -179,8 +179,6 @@ func dockerCmd() *cobra.Command {
179
179
log .Info (ctx , "got signal, canceling context" )
180
180
}()
181
181
182
- cmd .SetContext (ctx )
183
-
184
182
if flags .noStartupLogs {
185
183
log = slog .Make (slogjson .Sink (io .Discard ))
186
184
blog = buildlog.NopLogger {}
@@ -827,15 +825,19 @@ func runDockerCVM(ctx context.Context, log slog.Logger, client dockerutil.Client
827
825
828
826
go func () {
829
827
defer resp .Close ()
828
+ go func () {
829
+ // Also close the response reader when the context is canceled.
830
+ defer resp .Close ()
831
+ <- ctx .Done ()
832
+ }()
830
833
rd := io .LimitReader (resp .Reader , 1 << 10 )
831
834
_ , err := io .Copy (blog , rd )
832
835
if err != nil {
833
836
log .Error (ctx , "copy bootstrap output" , slog .Error (err ))
834
837
}
838
+ log .Debug (ctx , "bootstrap output copied" )
835
839
}()
836
840
837
- // We can't just call ExecInspect because there's a race where the cmd
838
- // hasn't been assigned a PID yet.
839
841
return bootstrapExec .ID , nil
840
842
}
841
843
0 commit comments