mirror of
https://github.com/containers/podman
synced 2024-10-19 16:54:07 +00:00
Switch to bufio Reader for exec streams
There were many situations that made exec act funky with input. pipes didn't work as expected, as well as sending input before the shell opened. Thinking about it, it seemed as though the issues were because of how os.Stdin buffers (it doesn't). Dropping this input had some weird consequences. Instead, read from os.Stdin as bufio.Reader, allowing the input to buffer before passing it to the container. Signed-off-by: Peter Hunt <pehunt@redhat.com>
This commit is contained in:
parent
9ba8dae0bf
commit
1df4dba0a0
|
@ -1,6 +1,7 @@
|
|||
package libpod
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
@ -361,7 +362,7 @@ type AttachStreams struct {
|
|||
// ErrorStream will be attached to container's STDERR
|
||||
ErrorStream io.WriteCloser
|
||||
// InputStream will be attached to container's STDIN
|
||||
InputStream io.Reader
|
||||
InputStream *bufio.Reader
|
||||
// AttachOutput is whether to attach to STDOUT
|
||||
// If false, stdout will not be attached
|
||||
AttachOutput bool
|
||||
|
|
|
@ -133,7 +133,9 @@ func (c *Container) runHealthCheck() (HealthCheckStatus, error) {
|
|||
streams := new(AttachStreams)
|
||||
streams.OutputStream = hcw
|
||||
streams.ErrorStream = hcw
|
||||
streams.InputStream = os.Stdin
|
||||
|
||||
streams.InputStream = bufio.NewReader(os.Stdin)
|
||||
|
||||
streams.AttachOutput = true
|
||||
streams.AttachError = true
|
||||
streams.AttachInput = true
|
||||
|
|
|
@ -891,7 +891,7 @@ func (r *LocalRuntime) execPS(c *libpod.Container, args []string) ([]string, err
|
|||
streams := new(libpod.AttachStreams)
|
||||
streams.OutputStream = wPipe
|
||||
streams.ErrorStream = wPipe
|
||||
streams.InputStream = os.Stdin
|
||||
streams.InputStream = bufio.NewReader(os.Stdin)
|
||||
streams.AttachOutput = true
|
||||
streams.AttachError = true
|
||||
streams.AttachInput = true
|
||||
|
@ -969,7 +969,7 @@ func (r *LocalRuntime) ExecContainer(ctx context.Context, cli *cliconfig.ExecVal
|
|||
streams.OutputStream = os.Stdout
|
||||
streams.ErrorStream = os.Stderr
|
||||
if cli.Interactive {
|
||||
streams.InputStream = os.Stdin
|
||||
streams.InputStream = bufio.NewReader(os.Stdin)
|
||||
streams.AttachInput = true
|
||||
}
|
||||
streams.AttachOutput = true
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package adapter
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
@ -61,7 +62,7 @@ func StartAttachCtr(ctx context.Context, ctr *libpod.Container, stdout, stderr,
|
|||
streams := new(libpod.AttachStreams)
|
||||
streams.OutputStream = stdout
|
||||
streams.ErrorStream = stderr
|
||||
streams.InputStream = stdin
|
||||
streams.InputStream = bufio.NewReader(stdin)
|
||||
streams.AttachOutput = true
|
||||
streams.AttachError = true
|
||||
streams.AttachInput = true
|
||||
|
|
|
@ -32,7 +32,7 @@ func setupStreams(call iopodman.VarlinkCall) (*bufio.Reader, *bufio.Writer, *io.
|
|||
|
||||
streams := libpod.AttachStreams{
|
||||
OutputStream: stdoutWriter,
|
||||
InputStream: pr,
|
||||
InputStream: bufio.NewReader(pr),
|
||||
// Runc eats the error stream
|
||||
ErrorStream: stdoutWriter,
|
||||
AttachInput: true,
|
||||
|
|
Loading…
Reference in a new issue