termenv_posix.go 336 B

1234567891011121314151617
  1. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
  2. // +build darwin dragonfly freebsd linux netbsd openbsd
  3. package termenv
  4. import (
  5. "golang.org/x/sys/unix"
  6. )
  7. func isForeground(fd int) bool {
  8. pgrp, err := unix.IoctlGetInt(fd, unix.TIOCGPGRP)
  9. if err != nil {
  10. return false
  11. }
  12. return pgrp == unix.Getpgrp()
  13. }