1 //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 2 // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 3 4 package watch 5 6 import ( 7 "golang.org/x/sys/unix" 8 ) 9 10 // enableCharInput is inspired from the Unix implementation of MakeRaw in golang.org/x/term 11 // It enables the treatment of input stream char by char instead of line by line 12 // See https://man7.org/linux/man-pages/man3/termios.3.html for reference 13 func enableCharInput(fd int) error { 14 termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios) 15 if err != nil { 16 return err 17 } 18 termios.Lflag &^= unix.ICANON 19 if err := unix.IoctlSetTermios(fd, ioctlWriteTermios, termios); err != nil { 20 return err 21 } 22 23 return nil 24 } 25