mirror of
https://github.com/containers/podman.git
synced 2025-05-17 23:26:08 +08:00
add default polling interval to Container.Wait
Signed-off-by: Maximilian Hueter <maximilian.hueter@icloud.com>
This commit is contained in:
@ -543,6 +543,8 @@ func (c *Container) Wait(ctx context.Context) (int32, error) {
|
|||||||
|
|
||||||
// WaitForExit blocks until the container exits and returns its exit code. The
|
// WaitForExit blocks until the container exits and returns its exit code. The
|
||||||
// argument is the interval at which checks the container's status.
|
// argument is the interval at which checks the container's status.
|
||||||
|
// If the argument is less than or equal to 0 Nanoseconds a default interval is
|
||||||
|
// used.
|
||||||
func (c *Container) WaitForExit(ctx context.Context, pollInterval time.Duration) (int32, error) {
|
func (c *Container) WaitForExit(ctx context.Context, pollInterval time.Duration) (int32, error) {
|
||||||
id := c.ID()
|
id := c.ID()
|
||||||
if !c.valid {
|
if !c.valid {
|
||||||
@ -593,6 +595,10 @@ func (c *Container) WaitForExit(ctx context.Context, pollInterval time.Duration)
|
|||||||
defer unix.Close(conmonPidFd)
|
defer unix.Close(conmonPidFd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if pollInterval <= 0 {
|
||||||
|
pollInterval = DefaultWaitInterval
|
||||||
|
}
|
||||||
|
|
||||||
// we cannot wait locked as we would hold the lock forever, so we unlock and then lock again
|
// we cannot wait locked as we would hold the lock forever, so we unlock and then lock again
|
||||||
c.lock.Unlock()
|
c.lock.Unlock()
|
||||||
err := waitForConmonExit(ctx, conmonPID, conmonPidFd, pollInterval)
|
err := waitForConmonExit(ctx, conmonPID, conmonPidFd, pollInterval)
|
||||||
|
Reference in New Issue
Block a user