summaryrefslogtreecommitdiff
path: root/libpod/container_api.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-03-09 09:49:27 -0400
committerMatthew Heon <matthew.heon@pm.me>2020-03-09 09:50:55 -0400
commit521ff14d83e387f39058c65361a68d83edae61ba (patch)
treeaa96412a8edff1efdce26dd4d03c31df3f72a867 /libpod/container_api.go
parentffce869daa6c4956bc1509b7b10726a266b74741 (diff)
downloadpodman-521ff14d83e387f39058c65361a68d83edae61ba.tar.gz
podman-521ff14d83e387f39058c65361a68d83edae61ba.tar.bz2
podman-521ff14d83e387f39058c65361a68d83edae61ba.zip
Revert "exec: get the exit code from sync pipe instead of file"
This reverts commit 4b72f9e4013411208751df2a92ab9f322d4da5b2. Continues what began with revert of d3d97a25e8c87cf741b2e24ac01ef84962137106 in previous commit. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/container_api.go')
-rw-r--r--libpod/container_api.go25
1 files changed, 8 insertions, 17 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index e5174c02c..039619ea6 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -282,16 +282,7 @@ func (c *Container) Exec(tty, privileged bool, env map[string]string, cmd []stri
opts.Resize = resize
opts.DetachKeys = detachKeys
- pid := 0
- pipeDataChan, attachChan, err := c.ociRuntime.ExecContainer(c, sessionID, opts)
- // if pipeDataChan isn't nil, we should set the err
- if pipeDataChan != nil {
- pidData := <-pipeDataChan
- if pidData.err != nil {
- err = pidData.err
- }
- pid = pidData.data
- }
+ pid, attachChan, err := c.ociRuntime.ExecContainer(c, sessionID, opts)
if err != nil {
ec := define.ExecErrorCodeGeneric
// Conmon will pass a non-zero exit code from the runtime as a pid here.
@@ -327,18 +318,18 @@ func (c *Container) Exec(tty, privileged bool, env map[string]string, cmd []stri
lastErr := <-attachChan
- exitCodeData := <-pipeDataChan
- if exitCodeData.err != nil {
+ exitCode, err := c.readExecExitCode(sessionID)
+ if err != nil {
if lastErr != nil {
logrus.Errorf(lastErr.Error())
}
- lastErr = exitCodeData.err
+ lastErr = err
}
- if exitCodeData.data != 0 {
+ if exitCode != 0 {
if lastErr != nil {
logrus.Errorf(lastErr.Error())
}
- lastErr = errors.Wrapf(define.ErrOCIRuntime, "non zero exit code: %d", exitCodeData.data)
+ lastErr = errors.Wrapf(define.ErrOCIRuntime, "non zero exit code: %d", exitCode)
}
// Lock again
@@ -349,7 +340,7 @@ func (c *Container) Exec(tty, privileged bool, env map[string]string, cmd []stri
// Sync the container again to pick up changes in state
if err := c.syncContainer(); err != nil {
logrus.Errorf("error syncing container %s state to remove exec session %s", c.ID(), sessionID)
- return exitCodeData.data, lastErr
+ return exitCode, lastErr
}
// Remove the exec session from state
@@ -357,7 +348,7 @@ func (c *Container) Exec(tty, privileged bool, env map[string]string, cmd []stri
if err := c.save(); err != nil {
logrus.Errorf("Error removing exec session %s from container %s state: %v", sessionID, c.ID(), err)
}
- return exitCodeData.data, lastErr
+ return exitCode, lastErr
}
// AttachStreams contains streams that will be attached to the container