Necessary when one has to pipe ``mc`` output to non terminal applications like ``less`` ``more`` etc.
19 lines
450 B
Go
19 lines
450 B
Go
// +build linux
|
|
|
|
package console
|
|
|
|
import (
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
// Standard ioctls from Linux - /usr/include/asm-generic/ioctls.h:#define TCGETS 0x5401
|
|
const ioctlReadTermios = syscall.TCGETS
|
|
|
|
// isatty return true if the file descriptor is terminal.
|
|
func isatty(fd uintptr) bool {
|
|
var termios syscall.Termios
|
|
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
|
|
return err == 0
|
|
}
|