From 518b0c17c0d409e9a3c2c08cad880751d2666e49 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 26 May 2021 10:40:36 +0200 Subject: [PATCH] Don't set termio in IsTerminal on solaris The current implementation of IsTerminal on solaris uses IoctlSetTermio which will set a zero valued termio on the given FD. This might lead to unexpected side effects. Instead, use IoctlGetTermio which will not change the terminal settings. Also adjust the reference to isatty in the Illumos source. --- isatty_solaris.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/isatty_solaris.go b/isatty_solaris.go index bdd5c79..3010670 100644 --- a/isatty_solaris.go +++ b/isatty_solaris.go @@ -8,10 +8,9 @@ import ( ) // IsTerminal returns true if the given file descriptor is a terminal. -// see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c +// see: https://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libc/port/gen/isatty.c func IsTerminal(fd uintptr) bool { - var termio unix.Termio - err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) + _, err := unix.IoctlGetTermio(int(fd), unix.TCGETA) return err == nil }