From 2cb9d26c2fcbda51c056a9a11c54a838d80e35e6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 16 Apr 2020 17:27:26 +0200 Subject: [PATCH] vendor: github.com/containerd/console v1.0.0 full diff: https://github.com/containerd/console/compare/0650fd9eeb50bab4fc99dceb9f2e14cf58f36e7f...v1.0.0 Signed-off-by: Sebastiaan van Stijn --- vendor.conf | 2 +- .../github.com/containerd/console/console.go | 19 +++++++++++-------- .../containerd/console/console_linux.go | 7 ++++++- .../containerd/console/console_unix.go | 6 +++--- .../containerd/console/console_windows.go | 4 ++-- vendor/github.com/containerd/console/go.mod | 8 ++++++++ 6 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 vendor/github.com/containerd/console/go.mod diff --git a/vendor.conf b/vendor.conf index 7bed1fdfbd..22036dc384 100755 --- a/vendor.conf +++ b/vendor.conf @@ -2,7 +2,7 @@ cloud.google.com/go 0ebda48a7f143b1cce9eb37a8c11 github.com/agl/ed25519 5312a61534124124185d41f09206b9fef1d88403 github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109 github.com/beorn7/perks e7f67b54abbeac9c40a31de0f81159e4cafebd6a -github.com/containerd/console 0650fd9eeb50bab4fc99dceb9f2e14cf58f36e7f +github.com/containerd/console 8375c3424e4d7b114e8a90a4a40c8e1b40d1d4e6 # v1.0.0 github.com/containerd/containerd 4d242818bf55542e5d7876ca276fea83029e803c github.com/containerd/continuity 26c1120b8d4107d2471b93ad78ef7ce1fc84c4c4 github.com/containerd/cgroups 44306b6a1d46985d916b48b4199f93a378af314f diff --git a/vendor/github.com/containerd/console/console.go b/vendor/github.com/containerd/console/console.go index c187a9b412..6a36d14776 100644 --- a/vendor/github.com/containerd/console/console.go +++ b/vendor/github.com/containerd/console/console.go @@ -24,10 +24,17 @@ import ( var ErrNotAConsole = errors.New("provided file is not a console") +type File interface { + io.ReadWriteCloser + + // Fd returns its file descriptor + Fd() uintptr + // Name returns its file name + Name() string +} + type Console interface { - io.Reader - io.Writer - io.Closer + File // Resize resizes the console to the provided window size Resize(WinSize) error @@ -42,10 +49,6 @@ type Console interface { Reset() error // Size returns the window size of the console Size() (WinSize, error) - // Fd returns the console's file descriptor - Fd() uintptr - // Name returns the console's file name - Name() string } // WinSize specifies the window size of the console @@ -70,7 +73,7 @@ func Current() Console { } // ConsoleFromFile returns a console using the provided file -func ConsoleFromFile(f *os.File) (Console, error) { +func ConsoleFromFile(f File) (Console, error) { if err := checkConsole(f); err != nil { return nil, err } diff --git a/vendor/github.com/containerd/console/console_linux.go b/vendor/github.com/containerd/console/console_linux.go index 42274e100e..c1c839ee3a 100644 --- a/vendor/github.com/containerd/console/console_linux.go +++ b/vendor/github.com/containerd/console/console_linux.go @@ -58,6 +58,7 @@ type Epoller struct { efd int mu sync.Mutex fdMapping map[int]*EpollConsole + closeOnce sync.Once } // NewEpoller returns an instance of epoller with a valid epoll fd. @@ -151,7 +152,11 @@ func (e *Epoller) getConsole(sysfd int) *EpollConsole { // Close closes the epoll fd func (e *Epoller) Close() error { - return unix.Close(e.efd) + closeErr := os.ErrClosed // default to "file already closed" + e.closeOnce.Do(func() { + closeErr = unix.Close(e.efd) + }) + return closeErr } // EpollConsole acts like a console but registers its file descriptor with an diff --git a/vendor/github.com/containerd/console/console_unix.go b/vendor/github.com/containerd/console/console_unix.go index a4a8d1267b..315f1d0c90 100644 --- a/vendor/github.com/containerd/console/console_unix.go +++ b/vendor/github.com/containerd/console/console_unix.go @@ -47,7 +47,7 @@ func NewPty() (Console, string, error) { } type master struct { - f *os.File + f File original *unix.Termios } @@ -122,7 +122,7 @@ func (m *master) Name() string { } // checkConsole checks if the provided file is a console -func checkConsole(f *os.File) error { +func checkConsole(f File) error { var termios unix.Termios if tcget(f.Fd(), &termios) != nil { return ErrNotAConsole @@ -130,7 +130,7 @@ func checkConsole(f *os.File) error { return nil } -func newMaster(f *os.File) (Console, error) { +func newMaster(f File) (Console, error) { m := &master{ f: f, } diff --git a/vendor/github.com/containerd/console/console_windows.go b/vendor/github.com/containerd/console/console_windows.go index 62dbe1c033..129a92883d 100644 --- a/vendor/github.com/containerd/console/console_windows.go +++ b/vendor/github.com/containerd/console/console_windows.go @@ -198,7 +198,7 @@ func makeInputRaw(fd windows.Handle, mode uint32) error { return nil } -func checkConsole(f *os.File) error { +func checkConsole(f File) error { var mode uint32 if err := windows.GetConsoleMode(windows.Handle(f.Fd()), &mode); err != nil { return err @@ -206,7 +206,7 @@ func checkConsole(f *os.File) error { return nil } -func newMaster(f *os.File) (Console, error) { +func newMaster(f File) (Console, error) { if f != os.Stdin && f != os.Stdout && f != os.Stderr { return nil, errors.New("creating a console from a file is not supported on windows") } diff --git a/vendor/github.com/containerd/console/go.mod b/vendor/github.com/containerd/console/go.mod new file mode 100644 index 0000000000..97b587d62d --- /dev/null +++ b/vendor/github.com/containerd/console/go.mod @@ -0,0 +1,8 @@ +module github.com/containerd/console + +go 1.13 + +require ( + github.com/pkg/errors v0.8.1 + golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e +)