summaryrefslogtreecommitdiff
path: root/libpod/oci.go
diff options
context:
space:
mode:
authorPeter Hunt <pehunt@redhat.com>2019-02-28 13:29:56 -0500
committerPeter Hunt <pehunt@redhat.com>2019-02-28 14:55:11 -0500
commitd780e69559d8aa117e154a234d10f2112c32c8be (patch)
tree859558158bd18ba14da6962970e3e2108428bd07 /libpod/oci.go
parent2e463b7720769d85dcdae516cad96c57e96b7464 (diff)
downloadpodman-d780e69559d8aa117e154a234d10f2112c32c8be.tar.gz
podman-d780e69559d8aa117e154a234d10f2112c32c8be.tar.bz2
podman-d780e69559d8aa117e154a234d10f2112c32c8be.zip
Allow Exec API user to override streams
Allow passing in of AttachStreams to libpod.Exec() for usage in podman healthcheck. An API caller can now specify different streams for stdout, stderr and stdin, or no streams at all. Signed-off-by: Peter Hunt <pehunt@redhat.com>
Diffstat (limited to 'libpod/oci.go')
-rw-r--r--libpod/oci.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/libpod/oci.go b/libpod/oci.go
index 26d2c6ef1..4bf76f619 100644
--- a/libpod/oci.go
+++ b/libpod/oci.go
@@ -733,7 +733,7 @@ func (r *OCIRuntime) unpauseContainer(ctr *Container) error {
// TODO: Add --detach support
// TODO: Convert to use conmon
// TODO: add --pid-file and use that to generate exec session tracking
-func (r *OCIRuntime) execContainer(c *Container, cmd, capAdd, env []string, tty bool, cwd, user, sessionID string) (*exec.Cmd, error) {
+func (r *OCIRuntime) execContainer(c *Container, cmd, capAdd, env []string, tty bool, cwd, user, sessionID string, streams *AttachStreams) (*exec.Cmd, error) {
if len(cmd) == 0 {
return nil, errors.Wrapf(ErrInvalidArg, "must provide a command to execute")
}
@@ -789,9 +789,17 @@ func (r *OCIRuntime) execContainer(c *Container, cmd, capAdd, env []string, tty
logrus.Debugf("Starting runtime %s with following arguments: %v", r.path, args)
execCmd := exec.Command(r.path, args...)
- execCmd.Stdout = os.Stdout
- execCmd.Stderr = os.Stderr
- execCmd.Stdin = os.Stdin
+
+ if streams.AttachOutput {
+ execCmd.Stdout = streams.OutputStream
+ }
+ if streams.AttachInput {
+ execCmd.Stdin = streams.InputStream
+ }
+ if streams.AttachError {
+ execCmd.Stderr = streams.ErrorStream
+ }
+
execCmd.Env = append(execCmd.Env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", runtimeDir))
if err := execCmd.Start(); err != nil {