diff options
author | Peter Hunt <pehunt@redhat.com> | 2020-03-02 14:42:48 -0500 |
---|---|---|
committer | Peter Hunt <pehunt@redhat.com> | 2020-03-03 15:35:35 -0500 |
commit | 4b72f9e4013411208751df2a92ab9f322d4da5b2 (patch) | |
tree | 21abdfa291eaca2da67b0115fa4eed93eaa5aaa7 /libpod/oci.go | |
parent | 3bc5f431d4df9724501a42a68e333f7e98a0b0cf (diff) | |
download | podman-4b72f9e4013411208751df2a92ab9f322d4da5b2.tar.gz podman-4b72f9e4013411208751df2a92ab9f322d4da5b2.tar.bz2 podman-4b72f9e4013411208751df2a92ab9f322d4da5b2.zip |
exec: get the exit code from sync pipe instead of file
Before, we were getting the exit code from the file, in which we waited an arbitrary amount of time (5 seconds) for the file, and segfaulted if we didn't find it. instead, we should be a bit more certain conmon has sent the exit code. Luckily, it sends the exit code along the sync pipe fd, so we can read it from there
Adapt the ExecContainer interface to pass along a channel to get the pid and exit code from conmon, to be able to read both from the pipe
Signed-off-by: Peter Hunt <pehunt@redhat.com>
Diffstat (limited to 'libpod/oci.go')
-rw-r--r-- | libpod/oci.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libpod/oci.go b/libpod/oci.go index 2ea61851f..e5f9b2135 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -70,7 +70,7 @@ type OCIRuntime interface { // ExecContainer executes a command in a running container. // Returns an int (exit code), error channel (errors from attach), and // error (errors that occurred attempting to start the exec session). - ExecContainer(ctr *Container, sessionID string, options *ExecOptions) (int, chan error, error) + ExecContainer(ctr *Container, sessionID string, options *ExecOptions) (chan DataAndErr, chan error, error) // ExecStopContainer stops a given exec session in a running container. // SIGTERM with be sent initially, then SIGKILL after the given timeout. // If timeout is 0, SIGKILL will be sent immediately, and SIGTERM will @@ -159,3 +159,10 @@ type HTTPAttachStreams struct { Stdout bool Stderr bool } + +// DataAndErr is a generic structure for passing around an int and an error +// it is especially useful for getting information from conmon +type DataAndErr struct { + data int + err error +} |