summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2018-10-01 10:45:26 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2018-10-03 21:39:35 +0200
commitc5546729b8ab0692d8e4358ca0763d813a495550 (patch)
treee436b42a36aa076a5b6d742d8e14d10ebb844498 /libpod
parentc21e85e5f444d486e6c22a4cc998d5c3dc2f6900 (diff)
downloadpodman-c5546729b8ab0692d8e4358ca0763d813a495550.tar.gz
podman-c5546729b8ab0692d8e4358ca0763d813a495550.tar.bz2
podman-c5546729b8ab0692d8e4358ca0763d813a495550.zip
oci: split the stdout and stderr pipes
read the OCI status from stdout, not the combined stdout+stderr stream. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/oci.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/libpod/oci.go b/libpod/oci.go
index 562c2fd4c..973dac73c 100644
--- a/libpod/oci.go
+++ b/libpod/oci.go
@@ -452,9 +452,20 @@ func (r *OCIRuntime) updateContainerStatus(ctr *Container) error {
cmd := exec.Command(r.path, "state", ctr.ID())
cmd.Env = append(cmd.Env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", runtimeDir))
-
- out, err := cmd.CombinedOutput()
+ outPipe, err := cmd.StdoutPipe()
+ if err != nil {
+ return errors.Wrapf(err, "getting stdout pipe")
+ }
+ errPipe, err := cmd.StderrPipe()
if err != nil {
+ return errors.Wrapf(err, "getting stderr pipe")
+ }
+
+ if err := cmd.Start(); err != nil {
+ out, err2 := ioutil.ReadAll(errPipe)
+ if err2 != nil {
+ return errors.Wrapf(err, "error getting container %s state", ctr.ID())
+ }
if strings.Contains(string(out), "does not exist") {
ctr.removeConmonFiles()
ctr.state.State = ContainerStateExited
@@ -462,6 +473,12 @@ func (r *OCIRuntime) updateContainerStatus(ctr *Container) error {
}
return errors.Wrapf(err, "error getting container %s state. stderr/out: %s", ctr.ID(), out)
}
+
+ errPipe.Close()
+ out, err := ioutil.ReadAll(outPipe)
+ if err != nil {
+ return errors.Wrapf(err, "error reading stdout: %s", ctr.ID())
+ }
if err := json.NewDecoder(bytes.NewBuffer(out)).Decode(state); err != nil {
return errors.Wrapf(err, "error decoding container status for container %s", ctr.ID())
}