Added terminal detection
This commit is contained in:
9
tty/Terminal_linux.go
Normal file
9
tty/Terminal_linux.go
Normal file
@ -0,0 +1,9 @@
|
||||
package tty
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
// IsTerminal returns true if the file descriptor is a terminal.
|
||||
func IsTerminal(fd uintptr) bool {
|
||||
_, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
|
||||
return err == nil
|
||||
}
|
Reference in New Issue
Block a user