summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container.go6
-rw-r--r--libpod/container_api.go13
2 files changed, 14 insertions, 5 deletions
diff --git a/libpod/container.go b/libpod/container.go
index fc613f406..0b1879208 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -36,8 +36,6 @@ const (
ContainerStateStopped ContainerStatus = iota
// ContainerStatePaused indicates that the container has been paused
ContainerStatePaused ContainerStatus = iota
- // WaitTimeout is the wait timeout before checking for container exit
- WaitTimeout = time.Second / time.Millisecond
)
// CgroupfsDefaultCgroupParent is the cgroup parent for CGroupFS in libpod
@@ -47,6 +45,10 @@ const CgroupfsDefaultCgroupParent = "/libpod_parent"
// manager in libpod
const SystemdDefaultCgroupParent = "machine.slice"
+// DefaultWaitInterval is the default interval between container status checks
+// while waiting.
+const DefaultWaitInterval = 250 * time.Millisecond
+
// LinuxNS represents a Linux namespace
type LinuxNS int
diff --git a/libpod/container_api.go b/libpod/container_api.go
index 76537ebc4..fc2058de6 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -593,13 +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
-func (c *Container) Wait(waitTimeout time.Duration) (int32, error) {
+// 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(waitTimeout*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