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

implemented IsTerminal() on Solaris #307

Closed
wants to merge 1 commit into from

Conversation

fazalmajid
Copy link

This is a Solaris implementation of IsTerminal(), based on golang/go#13085

_, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA)
fd := syscall.Stderr
var termio unix.Termio
err := unix.IoctlSetTermio(fd, unix.TCGETA, &termio)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this mutate the state of the file descriptor? seems like undesirable behavior from a method named IsTerminal

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused as to why this is calling IoctlSetTermio instead of IoctlGetTermio, and I'm also confused as to why this is assuming stderr specifically instead of stdout.

Can you explain that a bit more?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aybabtme & @binarycrusader: Good question. The code in question isn't present in the original git://golang.org/x/crypto/ssh/termina/util_solaris.go where I first implemented it.

stderr vs. stdout because I used terminal_notwindows.go as a starting point. Since IsTerminal() does not have an argument to specify which fd to test for terminal-ness, The rationale for @illicitonion's choice of stderr is here:
05f9567

I am no longer sure why I submitted this pull request. I suspect what happened is I implemented terminal_solaris.go some time ago to get InfluxDB or Prometheus to build on Solaris, and only later merged master back and pushed it, not realizing someone else had already implemented this independently:
8cdd4b3

I verified the code in the master branch works on Solaris (well, apart from the stdout vs. stderr issue). Feel free to disregard this pull request.

@fazalmajid
Copy link
Author

closed by 8cdd4b3

@fazalmajid fazalmajid closed this Feb 2, 2016
@sirupsen
Copy link
Owner

sirupsen commented Feb 2, 2016

Releasing master which will work with Solaris. Thanks @binarycrusader and @fazalmajid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants