mirror of
https://github.com/moby/moby.git
synced 2026-07-21 06:52:18 +00:00
Replace `time.Sleep` with a poll that checks if process no longer exists to avoid possible race condition. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
18 lines
394 B
Go
18 lines
394 B
Go
package process
|
|
|
|
import (
|
|
procpkg "github.com/docker/docker/pkg/process"
|
|
"gotest.tools/v3/poll"
|
|
)
|
|
|
|
// NotAlive verifies the process doesn't exist (finished or never started).
|
|
func NotAlive(pid int) func(log poll.LogT) poll.Result {
|
|
return func(log poll.LogT) poll.Result {
|
|
if !procpkg.Alive(pid) {
|
|
return poll.Success()
|
|
}
|
|
|
|
return poll.Continue("waiting for process to finish")
|
|
}
|
|
}
|