Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow to termStatusReport on a PTY #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import (
"sync"
)

var (
// output is the default global output.
output = NewOutput(os.Stdout)
)
// output is the default global output.
var output = NewOutput(os.Stdout)

// File represents a file descriptor.
//
Expand Down
13 changes: 0 additions & 13 deletions termenv_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,3 @@
// +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()
}
18 changes: 0 additions & 18 deletions termenv_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,3 @@
// +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
}
5 changes: 0 additions & 5 deletions termenv_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,6 @@ func (o Output) termStatusReport(sequence int) (string, error) {

if !o.unsafe {
fd := int(tty.Fd())
// if in background, we can't control the terminal
if !isForeground(fd) {
return "", ErrStatusReport
}

t, err := unix.IoctlGetTermios(fd, tcgetattr)
if err != nil {
return "", fmt.Errorf("%s: %s", ErrStatusReport, err)
Expand Down
Loading