Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support foreground detection on Solaris/illumos
- Loading branch information
Showing
3 changed files
with
39 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd | ||
// +build darwin dragonfly freebsd linux netbsd openbsd | ||
|
||
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//go:build solaris || illumos | ||
// +build solaris illumos | ||
|
||
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 | ||
} | ||
|
||
g, err := unix.Getpgrp() | ||
if err != nil { | ||
return false | ||
} | ||
|
||
return pgrp == g | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters