termenv_posix.go

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