summaryrefslogtreecommitdiff
path: root/libpod/container_internal.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_internal.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_internal.go')
-rw-r--r--libpod/container_internal.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 60b13f125..a0805c1fa 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -206,6 +206,28 @@ func (c *Container) execOCILog(sessionID string) string {
return filepath.Join(c.execBundlePath(sessionID), "oci-log")
}
+// readExecExitCode reads the exit file for an exec session and returns
+// the exit code
+func (c *Container) readExecExitCode(sessionID string) (int, error) {
+ exitFile := filepath.Join(c.execExitFileDir(sessionID), c.ID())
+ chWait := make(chan error)
+ defer close(chWait)
+
+ _, err := WaitForFile(exitFile, chWait, time.Second*5)
+ if err != nil {
+ return -1, err
+ }
+ ec, err := ioutil.ReadFile(exitFile)
+ if err != nil {
+ return -1, err
+ }
+ ecInt, err := strconv.Atoi(string(ec))
+ if err != nil {
+ return -1, err
+ }
+ return ecInt, nil
+}
+
// Wait for the container's exit file to appear.
// When it does, update our state based on it.
func (c *Container) waitForExitFileAndSync() error {