summaryrefslogtreecommitdiff
path: root/libpod/container_api.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-07-01 15:54:27 +0200
committerGitHub <noreply@github.com>2019-07-01 15:54:27 +0200
commit150778820f0f6d9f7ffdb672a8b136804378f025 (patch)
treeb959b53d288816c3c36fb5b054a19075d65a3c34 /libpod/container_api.go
parented394070a895654ad3ffbabd81a3033b0c7088ff (diff)
parent4f56964d556a7379c09a903258fd44c2232a686a (diff)
downloadpodman-150778820f0f6d9f7ffdb672a8b136804378f025.tar.gz
podman-150778820f0f6d9f7ffdb672a8b136804378f025.tar.bz2
podman-150778820f0f6d9f7ffdb672a8b136804378f025.zip
Merge pull request #3324 from marcov/detach-keys-configurable
libpod: specify a detach keys sequence in libpod.conf
Diffstat (limited to 'libpod/container_api.go')
-rw-r--r--libpod/container_api.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index 8d1e5751b..3dd84b02c 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -7,7 +7,6 @@ import (
"io/ioutil"
"os"
"strconv"
- "sync"
"time"
"github.com/containers/libpod/libpod/define"
@@ -120,20 +119,24 @@ func (c *Container) StartAndAttach(ctx context.Context, streams *AttachStreams,
attachChan := make(chan error)
// We need to ensure that we don't return until start() fired in attach.
- // Use a WaitGroup to sync this.
- wg := new(sync.WaitGroup)
- wg.Add(1)
+ // Use a channel to sync
+ startedChan := make(chan bool)
// Attach to the container before starting it
go func() {
- if err := c.attach(streams, keys, resize, true, wg); err != nil {
+ if err := c.attach(streams, keys, resize, true, startedChan); err != nil {
attachChan <- err
}
close(attachChan)
}()
- wg.Wait()
- c.newContainerEvent(events.Attach)
+ select {
+ case err := <-attachChan:
+ return nil, err
+ case <-startedChan:
+ c.newContainerEvent(events.Attach)
+ }
+
return attachChan, nil
}