summaryrefslogtreecommitdiff
path: root/vendor/github.com/muesli/termenv/termenv_posix.go
blob: c971dd998f06506afaf1abfd5510d219d4d5df45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || zos
// +build darwin dragonfly freebsd linux netbsd openbsd zos

package termenv

import (
	"golang.org/x/sys/unix"
)

func isForeground(fd int) bool {
	pgrp, err := unix.IoctlGetInt(fd, unix.TIOCGPGRP)
	if err != nil {
		return false
	}

	return pgrp == unix.Getpgrp()
}