diff options
Diffstat (limited to 'libpod/container_api.go')
| -rw-r--r-- | libpod/container_api.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go index 86e2370ea..fc2058de6 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -339,7 +339,9 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user string) e } pidFile := c.execPidPath(sessionID) - const pidWaitTimeout = 250 + // 1 second seems a reasonable time to wait + // See https://github.com/containers/libpod/issues/1495 + const pidWaitTimeout = 1000 // Wait until the runtime makes the pidfile // TODO: If runtime errors before the PID file is created, we have to @@ -591,14 +593,20 @@ func (c *Container) Inspect(size bool) (*inspect.ContainerInspectData, error) { return c.getContainerInspectData(size, driverData) } -// Wait blocks on a container to exit and returns its exit code +// Wait blocks until the container exits and returns its exit code. func (c *Container) Wait() (int32, error) { + return c.WaitWithInterval(DefaultWaitInterval) +} + +// WaitWithInterval blocks until the container to exit and returns its exit +// code. The argument is the interval at which checks the container's status. +func (c *Container) WaitWithInterval(waitTimeout time.Duration) (int32, error) { if !c.valid { return -1, ErrCtrRemoved } - - err := wait.PollImmediateInfinite(100*time.Millisecond, + err := wait.PollImmediateInfinite(waitTimeout, func() (bool, error) { + logrus.Debugf("Checking container %s status...", c.ID()) stopped, err := c.isStopped() if err != nil { return false, err |
