Update console dep to 84eeaae905fa414d03e07bcd6c8d

This change removes the ClearONLCR from the console package providing
a console with the default settings from the console package.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2017-09-25 11:58:12 -04:00
parent bd1f89b73f
commit ed811896ed
5 changed files with 44 additions and 29 deletions

View File

@ -1,6 +1,6 @@
github.com/coreos/go-systemd 48702e0da86bd25e76cfef347e2adeb434a0d0a6
github.com/containerd/go-runc b3c048c028ddd789c6f9510c597f8b9c62f25359
github.com/containerd/console b28c739c79ce69d017e3691ad3664568d68e95c6
github.com/containerd/console 84eeaae905fa414d03e07bcd6c8d3f19e7cf180e
github.com/containerd/cgroups 5933ab4dc4f7caa3a73a1dc141bd11f42b5c9163
github.com/containerd/typeurl f6943554a7e7e88b3c14aad190bf05932da84788
github.com/docker/go-metrics 8fd5772bf1584597834c6f7961a530f06cbfbb87

View File

@ -44,7 +44,13 @@ type WinSize struct {
// Current returns the current processes console
func Current() Console {
return newMaster(os.Stdin)
c, err := ConsoleFromFile(os.Stdin)
if err != nil {
// stdin should always be a console for the design
// of this function
panic(err)
}
return c
}
// ConsoleFromFile returns a console using the provided file
@ -52,5 +58,5 @@ func ConsoleFromFile(f *os.File) (Console, error) {
if err := checkConsole(f); err != nil {
return nil, err
}
return newMaster(f), nil
return newMaster(f)
}

View File

@ -16,9 +16,6 @@ func NewPty() (Console, string, error) {
if err != nil {
return nil, "", err
}
if err := saneTerminal(f); err != nil {
return nil, "", err
}
slave, err := ptsname(f)
if err != nil {
return nil, "", err
@ -26,9 +23,11 @@ func NewPty() (Console, string, error) {
if err := unlockpt(f); err != nil {
return nil, "", err
}
return &master{
f: f,
}, slave, nil
m, err := newMaster(f)
if err != nil {
return nil, "", err
}
return m, slave, nil
}
type master struct {
@ -72,9 +71,6 @@ func (m *master) getCurrent() (unix.Termios, error) {
if err := tcget(m.f.Fd(), &termios); err != nil {
return unix.Termios{}, err
}
if m.original == nil {
m.original = &termios
}
return termios, nil
}
@ -118,17 +114,29 @@ func checkConsole(f *os.File) error {
return nil
}
func newMaster(f *os.File) Console {
return &master{
func newMaster(f *os.File) (Console, error) {
m := &master{
f: f,
}
t, err := m.getCurrent()
if err != nil {
return nil, err
}
m.original = &t
return m, nil
}
// SaneTerminal sets the necessary tty_ioctl(4)s to ensure that a pty pair
// ClearONLCR sets the necessary tty_ioctl(4)s to ensure that a pty pair
// created by us acts normally. In particular, a not-very-well-known default of
// Linux unix98 ptys is that they have +onlcr by default. While this isn't a
// problem for terminal emulators, because we relay data from the terminal we
// also relay that funky line discipline.
func SaneTerminal(f *os.File) error {
return saneTerminal(f)
func ClearONLCR(fd uintptr) error {
return setONLCR(fd, false)
}
// SetONLCR sets the necessary tty_ioctl(4)s to ensure that a pty pair
// created by us acts as intended for a terminal emulator.
func SetONLCR(fd uintptr) error {
return setONLCR(fd, true)
}

View File

@ -190,13 +190,11 @@ func checkConsole(f *os.File) error {
return nil
}
func newMaster(f *os.File) Console {
func newMaster(f *os.File) (Console, error) {
if f != os.Stdin && f != os.Stdout && f != os.Stderr {
panic("creating a console from a file is not supported on windows")
return nil, errors.New("creating a console from a file is not supported on windows")
}
m := &master{}
m.initStdios()
return m
return m, nil
}

View File

@ -3,8 +3,6 @@
package console
import (
"os"
"golang.org/x/sys/unix"
)
@ -49,14 +47,19 @@ func tcswinsz(fd uintptr, ws WinSize) error {
return unix.IoctlSetWinsize(int(fd), unix.TIOCSWINSZ, &uws)
}
func saneTerminal(f *os.File) error {
func setONLCR(fd uintptr, enable bool) error {
var termios unix.Termios
if err := tcget(f.Fd(), &termios); err != nil {
if err := tcget(fd, &termios); err != nil {
return err
}
if enable {
// Set +onlcr so we can act like a real terminal
termios.Oflag |= unix.ONLCR
} else {
// Set -onlcr so we don't have to deal with \r.
termios.Oflag &^= unix.ONLCR
return tcset(f.Fd(), &termios)
}
return tcset(fd, &termios)
}
func cfmakeraw(t unix.Termios) unix.Termios {