summaryrefslogtreecommitdiff
path: root/libpod/container_attach.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2017-11-15 17:58:26 -0500
committerGitHub <noreply@github.com>2017-11-15 17:58:26 -0500
commitbf8b9a37df2aeead009996875f58c59625110472 (patch)
tree73d21edb601163fa907049a10c152917cc766a57 /libpod/container_attach.go
parentafe1a2e7f1a54946d86588398c37c6d52c4e125c (diff)
parentacd9c668647d273488772bfcb06a0f1a44dfb411 (diff)
downloadpodman-bf8b9a37df2aeead009996875f58c59625110472.tar.gz
podman-bf8b9a37df2aeead009996875f58c59625110472.tar.bz2
podman-bf8b9a37df2aeead009996875f58c59625110472.zip
Merge pull request #47 from baude/terminal_attach
Fix terminal attach
Diffstat (limited to 'libpod/container_attach.go')
-rw-r--r--libpod/container_attach.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/libpod/container_attach.go b/libpod/container_attach.go
index e308df4a4..8c1c98fe5 100644
--- a/libpod/container_attach.go
+++ b/libpod/container_attach.go
@@ -2,6 +2,7 @@ package libpod
import (
"fmt"
+ "golang.org/x/crypto/ssh/terminal"
"io"
"net"
"os"
@@ -25,7 +26,7 @@ const (
)
// attachContainerSocket connects to the container's attach socket and deals with the IO
-func (c *Container) attachContainerSocket(resize <-chan remotecommand.TerminalSize, noStdIn bool, detachKeys []byte) error {
+func (c *Container) attachContainerSocket(resize <-chan remotecommand.TerminalSize, noStdIn bool, detachKeys []byte, attached chan<- bool) error {
inputStream := os.Stdin
outputStream := os.Stdout
errorStream := os.Stderr
@@ -38,12 +39,14 @@ func (c *Container) attachContainerSocket(resize <-chan remotecommand.TerminalSi
return errors.Errorf("no tty available for %s", c.ID())
}
- oldTermState, err := term.SaveState(inputStream.Fd())
- if err != nil {
- return errors.Wrapf(err, "unable to save terminal state")
- }
+ if terminal.IsTerminal(int(inputStream.Fd())) {
+ oldTermState, err := term.SaveState(inputStream.Fd())
+ if err != nil {
+ return errors.Wrapf(err, "unable to save terminal state")
+ }
- defer term.RestoreTerminal(inputStream.Fd(), oldTermState)
+ defer term.RestoreTerminal(inputStream.Fd(), oldTermState)
+ }
// Put both input and output into raw
if !noStdIn {
@@ -71,6 +74,9 @@ func (c *Container) attachContainerSocket(resize <-chan remotecommand.TerminalSi
}
defer conn.Close()
+ // signal back that the connection was made
+ attached <- true
+
receiveStdoutError := make(chan error)
if outputStream != nil || errorStream != nil {
go func() {