exec: fix pipes

In a largely anticlimatic solution to the saga of piped input from conmon, we come to this solution.

When we pass the Stdin stream to the exec.Command structure, it's immediately consumed and lost, instead of being consumed through CopyDetachable().

When we don't pass -i in, conmon is not told to create a masterfd_stdin, and won't pass anything to the container.

With both, we can do

echo hi | podman exec -til cat

and get the expected hi

Downstream-patch: podman-1807379.patch
Signed-off-by: Peter Hunt <pehunt@redhat.com>
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Peter Hunt
2020-01-08 11:09:07 -05:00
committed by Valentin Rothberg
parent cfee21011c
commit 7286c00ace

View File

@ -543,6 +543,10 @@ func (r *ConmonOCIRuntime) ExecContainer(c *Container, sessionID string, options
args = append(args, "-t")
}
if options.Streams.AttachInput {
args = append(args, "-i")
}
// Append container ID and command
args = append(args, "-e")
// TODO make this optional when we can detach
@ -555,9 +559,8 @@ func (r *ConmonOCIRuntime) ExecContainer(c *Container, sessionID string, options
execCmd := exec.Command(r.conmonPath, args...)
if options.Streams != nil {
if options.Streams.AttachInput {
execCmd.Stdin = options.Streams.InputStream
}
// Don't add the InputStream to the execCmd. Instead, the data should be passed
// through CopyDetachable
if options.Streams.AttachOutput {
execCmd.Stdout = options.Streams.OutputStream
}