summaryrefslogtreecommitdiff
path: root/libpod/util.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-02-27 13:51:43 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-03-01 21:17:51 +0000
commit8b87a17f569010d694a124848d1489f8c1430516 (patch)
tree0b9a389f40f1ccbeb142635f84fadfdd66e4e5db /libpod/util.go
parentaea4f24919dcf5797f046465958c082ac3cba730 (diff)
downloadpodman-8b87a17f569010d694a124848d1489f8c1430516.tar.gz
podman-8b87a17f569010d694a124848d1489f8c1430516.tar.bz2
podman-8b87a17f569010d694a124848d1489f8c1430516.zip
Add tracking for exec session IDs
Exec sessions now have an ID generated and assigned to their PID and stored in the database state. This allows us to track what exec sessions are currently active. Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #412 Approved by: baude
Diffstat (limited to 'libpod/util.go')
-rw-r--r--libpod/util.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/libpod/util.go b/libpod/util.go
index 0c6700fbf..ca93fc097 100644
--- a/libpod/util.go
+++ b/libpod/util.go
@@ -107,3 +107,32 @@ func MountExists(specMounts []spec.Mount, dest string) bool {
}
return false
}
+
+// WaitForFile waits until a file has been created or the given timeout has occurred
+func WaitForFile(path string, timeout time.Duration) error {
+ done := make(chan struct{})
+ chControl := make(chan struct{})
+ go func() {
+ for {
+ select {
+ case <-chControl:
+ return
+ default:
+ _, err := os.Stat(path)
+ if err == nil {
+ close(done)
+ return
+ }
+ time.Sleep(25 * time.Millisecond)
+ }
+ }
+ }()
+
+ select {
+ case <-done:
+ return nil
+ case <-time.After(timeout):
+ close(chControl)
+ return errors.Wrapf(ErrInternal, "timed out waiting for file %s", path)
+ }
+}