diff options
Diffstat (limited to 'container/syscall.go')
| -rw-r--r-- | container/syscall.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/container/syscall.go b/container/syscall.go index 20ac068d..edb6e7e3 100644 --- a/container/syscall.go +++ b/container/syscall.go @@ -2,6 +2,7 @@ package container import ( "syscall" + "unsafe" ) // SetPtracer allows processes to ptrace(2) the calling process. @@ -37,6 +38,18 @@ func SetNoNewPrivs() error { return errno } +// Isatty tests whether a file descriptor refers to a terminal. +func Isatty(fd int) bool { + var buf [8]byte + r, _, _ := syscall.Syscall( + syscall.SYS_IOCTL, + uintptr(fd), + syscall.TIOCGWINSZ, + uintptr(unsafe.Pointer(&buf[0])), + ) + return r == 0 +} + // IgnoringEINTR makes a function call and repeats it if it returns an // EINTR error. This appears to be required even though we install all // signal handlers with SA_RESTART: see #22838, #38033, #38836, #40846. |
