summaryrefslogtreecommitdiff
path: root/pkg/adapter/terminal_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/adapter/terminal_linux.go')
-rw-r--r--pkg/adapter/terminal_linux.go31
1 files changed, 6 insertions, 25 deletions
diff --git a/pkg/adapter/terminal_linux.go b/pkg/adapter/terminal_linux.go
index 6e63dd87b..26cfd7b5e 100644
--- a/pkg/adapter/terminal_linux.go
+++ b/pkg/adapter/terminal_linux.go
@@ -6,7 +6,6 @@ import (
"os"
"github.com/containers/libpod/libpod"
- "github.com/docker/docker/pkg/term"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh/terminal"
@@ -27,7 +26,11 @@ func ExecAttachCtr(ctx context.Context, ctr *libpod.Container, tty, privileged b
return -1, err
}
defer cancel()
- defer restoreTerminal(oldTermState)
+ defer func() {
+ if err := restoreTerminal(oldTermState); err != nil {
+ logrus.Errorf("unable to restore terminal: %q", err)
+ }
+ }()
}
return ctr.Exec(tty, privileged, env, cmd, user, workDir, streams, preserveFDs, resize, detachKeys)
}
@@ -35,7 +38,7 @@ func ExecAttachCtr(ctx context.Context, ctr *libpod.Container, tty, privileged b
// StartAttachCtr starts and (if required) attaches to a container
// if you change the signature of this function from os.File to io.Writer, it will trigger a downstream
// error. we may need to just lint disable this one.
-func StartAttachCtr(ctx context.Context, ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys string, sigProxy bool, startContainer bool, recursive bool) error {
+func StartAttachCtr(ctx context.Context, ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys string, sigProxy bool, startContainer bool, recursive bool) error { //nolint-interfacer
resize := make(chan remotecommand.TerminalSize)
haveTerminal := terminal.IsTerminal(int(os.Stdin.Fd()))
@@ -104,25 +107,3 @@ func StartAttachCtr(ctx context.Context, ctr *libpod.Container, stdout, stderr,
return nil
}
-
-func handleTerminalAttach(ctx context.Context, resize chan remotecommand.TerminalSize) (context.CancelFunc, *term.State, error) {
- logrus.Debugf("Handling terminal attach")
-
- subCtx, cancel := context.WithCancel(ctx)
-
- resizeTty(subCtx, resize)
-
- oldTermState, err := term.SaveState(os.Stdin.Fd())
- if err != nil {
- // allow caller to not have to do any cleaning up if we error here
- cancel()
- return nil, nil, errors.Wrapf(err, "unable to save terminal state")
- }
-
- logrus.SetFormatter(&RawTtyFormatter{})
- if _, err := term.SetRawTerminal(os.Stdin.Fd()); err != nil {
- return nil, nil, err
- }
-
- return cancel, oldTermState, nil
-}