Skip to content

Commit 28eb6a8

Browse files
author
haoyun
committed
fix: call wait before start
1 parent ff93238 commit 28eb6a8

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

cmd/nerdctl/container/container_run.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ func runAction(cmd *cobra.Command, args []string) error {
435435
if err != nil {
436436
return err
437437
}
438+
439+
statusC, err := task.Wait(ctx)
440+
if err != nil {
441+
return err
442+
}
443+
438444
if err := task.Start(ctx); err != nil {
439445
return err
440446
}
@@ -454,10 +460,6 @@ func runAction(cmd *cobra.Command, args []string) error {
454460
}
455461
}
456462

457-
statusC, err := task.Wait(ctx)
458-
if err != nil {
459-
return err
460-
}
461463
select {
462464
// io.Wait() would return when either 1) the user detaches from the container OR 2) the container is about to exit.
463465
//

pkg/containerutil/containerutil.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ func Start(ctx context.Context, container containerd.Container, isAttach bool, i
279279
if err != nil {
280280
return err
281281
}
282-
282+
statusC, err := task.Wait(ctx)
283+
if err != nil {
284+
return err
285+
}
283286
if err := task.Start(ctx); err != nil {
284287
return err
285288
}
@@ -293,11 +296,6 @@ func Start(ctx context.Context, container containerd.Container, isAttach bool, i
293296
}
294297
sigc := signalutil.ForwardAllSignals(ctx, task)
295298
defer signalutil.StopCatch(sigc)
296-
297-
statusC, err := task.Wait(ctx)
298-
if err != nil {
299-
return err
300-
}
301299
select {
302300
// io.Wait() would return when either 1) the user detaches from the container OR 2) the container is about to exit.
303301
//

0 commit comments

Comments
 (0)