diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-04-11 14:44:11 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-04-13 18:43:44 +0000 |
commit | 6609d555f75568bb4f1394736a3e3b31e5f0d355 (patch) | |
tree | 92cfca059a58882d205acd2c575b587850ae1798 /cmd/podman/utils.go | |
parent | 5e03cec7ec83f8ff8b31a89a6180dda203b04d9c (diff) | |
download | podman-6609d555f75568bb4f1394736a3e3b31e5f0d355.tar.gz podman-6609d555f75568bb4f1394736a3e3b31e5f0d355.tar.bz2 podman-6609d555f75568bb4f1394736a3e3b31e5f0d355.zip |
Fix terminal attach
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #608
Approved by: baude
Diffstat (limited to 'cmd/podman/utils.go')
-rw-r--r-- | cmd/podman/utils.go | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/cmd/podman/utils.go b/cmd/podman/utils.go index 502424403..0238fc9c2 100644 --- a/cmd/podman/utils.go +++ b/cmd/podman/utils.go @@ -65,8 +65,9 @@ func getRuntime(c *cli.Context) (*libpod.Runtime, error) { } // Attach to a container -func attachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys string) error { +func attachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys string, sigProxy bool) error { resize := make(chan remotecommand.TerminalSize) + defer close(resize) haveTerminal := terminal.IsTerminal(int(os.Stdin.Fd())) @@ -87,12 +88,17 @@ func attachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys defer term.RestoreTerminal(os.Stdin.Fd(), oldTermState) } + if sigProxy { + ProxySignals(ctr) + } + return ctr.Attach(stdout, stderr, stdin, detachKeys, resize) } // Start and attach to a container -func startAttachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys string) (<-chan error, error) { +func startAttachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys string, sigProxy bool) error { resize := make(chan remotecommand.TerminalSize) + defer close(resize) haveTerminal := terminal.IsTerminal(int(os.Stdin.Fd())) @@ -105,7 +111,7 @@ func startAttachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detac oldTermState, err := term.SaveState(os.Stdin.Fd()) if err != nil { - return nil, errors.Wrapf(err, "unable to save terminal state") + return errors.Wrapf(err, "unable to save terminal state") } term.SetRawTerminal(os.Stdin.Fd()) @@ -113,7 +119,21 @@ func startAttachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detac defer term.RestoreTerminal(os.Stdin.Fd(), oldTermState) } - return ctr.StartAndAttach(stdout, stderr, stdin, detachKeys, resize) + attachChan, err := ctr.StartAndAttach(stdout, stderr, stdin, detachKeys, resize) + if err != nil { + return err + } + + if sigProxy { + ProxySignals(ctr) + } + + err = <-attachChan + if err != nil { + return errors.Wrapf(err, "error attaching to container %s", ctr.ID()) + } + + return nil } // Helper for prepareAttach - set up a goroutine to generate terminal resize events |