Files
privatae-bastion/client-go/stdio_console_linux.go
T
Privatae e4c9b69b46
ci / personal-data (push) Successful in 5s
ci / test (push) Successful in 3m4s
ci / fuzz (push) Successful in 3m45s
bastion 0.53.2
2026-10-20 04:42:14 +00:00

27 lines
559 B
Go

//go:build linux
package main
import (
"os"
"golang.org/x/sys/unix"
)
// stdioIsConsole: both standard input and standard output are a terminal, not
// a file or a pipe.
func stdioIsConsole() bool {
for _, f := range []*os.File{os.Stdin, os.Stdout} {
if _, err := unix.IoctlGetTermios(int(f.Fd()), unix.TCGETS); err != nil {
return false
}
}
return true
}
// stdinIsConsole: standard input alone is a terminal (pair_stdin.go).
func stdinIsConsole() bool {
_, err := unix.IoctlGetTermios(int(os.Stdin.Fd()), unix.TCGETS)
return err == nil
}