@@ -352,20 +352,29 @@ func (c *Container) Pid() int {
352
352
// Wait waits for the container to exit, and returns its WaitStatus.
353
353
func (c * Container ) Wait () (syscall.WaitStatus , error ) {
354
354
log .Debugf ("Wait on container %q" , c .ID )
355
+ if c .Status == Stopped {
356
+ return 0 , fmt .Errorf ("container is stopped" )
357
+ }
355
358
return c .Sandbox .Wait (c .ID )
356
359
}
357
360
358
361
// WaitRootPID waits for process 'pid' in the sandbox's PID namespace and
359
362
// returns its WaitStatus.
360
363
func (c * Container ) WaitRootPID (pid int32 ) (syscall.WaitStatus , error ) {
361
364
log .Debugf ("Wait on pid %d in sandbox %q" , pid , c .Sandbox .ID )
365
+ if c .Status == Stopped {
366
+ return 0 , fmt .Errorf ("container is stopped" )
367
+ }
362
368
return c .Sandbox .WaitPID (pid , c .Sandbox .ID )
363
369
}
364
370
365
371
// WaitPID waits for process 'pid' in the container's PID namespace and returns
366
372
// its WaitStatus.
367
373
func (c * Container ) WaitPID (pid int32 ) (syscall.WaitStatus , error ) {
368
374
log .Debugf ("Wait on pid %d in container %q" , pid , c .ID )
375
+ if c .Status == Stopped {
376
+ return 0 , fmt .Errorf ("container is stopped" )
377
+ }
369
378
return c .Sandbox .WaitPID (pid , c .ID )
370
379
}
371
380
0 commit comments