mirror of https://github.com/docker/cli.git
vendor: github.com/containerd/console v1.0.0
full diff: 0650fd9eeb
...v1.0.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c085577685
commit
2cb9d26c2f
|
@ -2,7 +2,7 @@ cloud.google.com/go 0ebda48a7f143b1cce9eb37a8c11
|
||||||
github.com/agl/ed25519 5312a61534124124185d41f09206b9fef1d88403
|
github.com/agl/ed25519 5312a61534124124185d41f09206b9fef1d88403
|
||||||
github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109
|
github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109
|
||||||
github.com/beorn7/perks e7f67b54abbeac9c40a31de0f81159e4cafebd6a
|
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/containerd 4d242818bf55542e5d7876ca276fea83029e803c
|
||||||
github.com/containerd/continuity 26c1120b8d4107d2471b93ad78ef7ce1fc84c4c4
|
github.com/containerd/continuity 26c1120b8d4107d2471b93ad78ef7ce1fc84c4c4
|
||||||
github.com/containerd/cgroups 44306b6a1d46985d916b48b4199f93a378af314f
|
github.com/containerd/cgroups 44306b6a1d46985d916b48b4199f93a378af314f
|
||||||
|
|
|
@ -24,10 +24,17 @@ import (
|
||||||
|
|
||||||
var ErrNotAConsole = errors.New("provided file is not a console")
|
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 {
|
type Console interface {
|
||||||
io.Reader
|
File
|
||||||
io.Writer
|
|
||||||
io.Closer
|
|
||||||
|
|
||||||
// Resize resizes the console to the provided window size
|
// Resize resizes the console to the provided window size
|
||||||
Resize(WinSize) error
|
Resize(WinSize) error
|
||||||
|
@ -42,10 +49,6 @@ type Console interface {
|
||||||
Reset() error
|
Reset() error
|
||||||
// Size returns the window size of the console
|
// Size returns the window size of the console
|
||||||
Size() (WinSize, error)
|
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
|
// WinSize specifies the window size of the console
|
||||||
|
@ -70,7 +73,7 @@ func Current() Console {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConsoleFromFile returns a console using the provided file
|
// 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 {
|
if err := checkConsole(f); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ type Epoller struct {
|
||||||
efd int
|
efd int
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
fdMapping map[int]*EpollConsole
|
fdMapping map[int]*EpollConsole
|
||||||
|
closeOnce sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewEpoller returns an instance of epoller with a valid epoll fd.
|
// 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
|
// Close closes the epoll fd
|
||||||
func (e *Epoller) Close() error {
|
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
|
// EpollConsole acts like a console but registers its file descriptor with an
|
||||||
|
|
|
@ -47,7 +47,7 @@ func NewPty() (Console, string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type master struct {
|
type master struct {
|
||||||
f *os.File
|
f File
|
||||||
original *unix.Termios
|
original *unix.Termios
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ func (m *master) Name() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkConsole checks if the provided file is a console
|
// checkConsole checks if the provided file is a console
|
||||||
func checkConsole(f *os.File) error {
|
func checkConsole(f File) error {
|
||||||
var termios unix.Termios
|
var termios unix.Termios
|
||||||
if tcget(f.Fd(), &termios) != nil {
|
if tcget(f.Fd(), &termios) != nil {
|
||||||
return ErrNotAConsole
|
return ErrNotAConsole
|
||||||
|
@ -130,7 +130,7 @@ func checkConsole(f *os.File) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMaster(f *os.File) (Console, error) {
|
func newMaster(f File) (Console, error) {
|
||||||
m := &master{
|
m := &master{
|
||||||
f: f,
|
f: f,
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,7 @@ func makeInputRaw(fd windows.Handle, mode uint32) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkConsole(f *os.File) error {
|
func checkConsole(f File) error {
|
||||||
var mode uint32
|
var mode uint32
|
||||||
if err := windows.GetConsoleMode(windows.Handle(f.Fd()), &mode); err != nil {
|
if err := windows.GetConsoleMode(windows.Handle(f.Fd()), &mode); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -206,7 +206,7 @@ func checkConsole(f *os.File) error {
|
||||||
return nil
|
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 {
|
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")
|
return nil, errors.New("creating a console from a file is not supported on windows")
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
)
|
Loading…
Reference in New Issue