Skip to content

Commit

Permalink
Don't set termio in IsTerminal on solaris
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tklauser committed May 26, 2021
1 parent 3751eb4 commit 518b0c1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions isatty_solaris.go
Expand Up @@ -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
}

Expand Down

0 comments on commit 518b0c1

Please sign in to comment.