Merge pull request #1259 from dqminh/epoll-io

Use Epoll to perform I/O in linux
This commit is contained in:
Stephen Day
2017-07-31 13:47:41 -07:00
committed by GitHub
10 changed files with 210 additions and 22 deletions

View File

@@ -28,6 +28,8 @@ type Console interface {
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

View File

@@ -1,4 +1,5 @@
// +build linux
package console
import (

View File

@@ -118,6 +118,10 @@ func (m *master) Fd() uintptr {
return m.f.Fd()
}
func (m *master) Name() string {
return m.f.Name()
}
// checkConsole checks if the provided file is a console
func checkConsole(f *os.File) error {
var termios unix.Termios
@@ -132,3 +136,12 @@ func newMaster(f *os.File) Console {
f: f,
}
}
// SaneTerminal 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)
}

View File

@@ -154,6 +154,13 @@ func (m *master) Fd() uintptr {
return m.in
}
// on windows, console can only be made from os.Std{in,out,err}, hence there
// isnt a single name here we can use. Return a dummy "console" value in this
// case should be sufficient.
func (m *master) Name() string {
return "console"
}
// makeInputRaw puts the terminal (Windows Console) connected to the given
// file descriptor into raw mode
func makeInputRaw(fd uintptr, mode uint32) error {