sshpiper/cmd/sshpiperd/internal/plugin/tty.go
Boshi Lian 319824e564 align log level across plugins
happy lint

happy lint
2022-08-05 23:08:01 +00:00

25 lines
375 B
Go

package plugin
import (
"io"
"os"
"golang.org/x/sys/unix"
)
const ioctlReadTermios = unix.TCGETS
func isTerminal(fd int) bool {
_, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
return err == nil
}
// code from logrus
func checkIfTerminal(w io.Writer) bool {
switch v := w.(type) {
case *os.File:
return isTerminal(int(v.Fd()))
default:
return false
}
}