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

x/crypto/ssh/terminal: cannot use syscall.Stdin (type syscall.Handle) as type int in argument to terminal.IsTerminal #12978

Closed
techtonik opened this issue Oct 18, 2015 · 12 comments

Comments

@techtonik
Copy link

This warnings are Windows only:

lxc\config.go:99: cannot use syscall.Stdin (type syscall.Handle) as type int in argument to terminal.IsTerminal
lxc\config.go:345: cannot use syscall.Stdin (type syscall.Handle) as type int in argument to terminal.IsTerminal
lxc\exec.go:57: cannot use syscall.Stdout (type syscall.Handle) as type int in argument to terminal.GetSize

And the code in lxc\config.go:99 is this:

    if !terminal.IsTerminal(syscall.Stdin) && value == "-" {

How to fix that? Is it a Go bug?

@bradfitz
Copy link
Contributor

I don't think the x/crypto/ssh/terminal package supports Windows.

This isn't a bug in Go, but a lack of implementation in an external package.

@bradfitz
Copy link
Contributor

Nevermind, the x/crypto/ssh/terminal package does support Windows and build.golang.org says it's passing its tests. I see the code for Windows in x/crypto/ssh/terminal and I can install it fine:

bradfitz@debian:~/src/golang.org/x/crypto/ssh/terminal$ GOOS=windows go install .

Your error message contains lxc/.

I think you have the wrong bug tracker. I don't know what package you're compiling, but it's not in the Go repos anywhere.

@techtonik
Copy link
Author

@bradfitz are you sure there are tests for this part?

@techtonik
Copy link
Author

This is the package https://github.com/lxc/lxd/blob/master/lxc/config.go#L98

go get github.com/lxc/lxd
cd %GOPATH%\src\github.com\lxc\lxd
go get -t -v -d ./...
go install -v ./lxc

It works on Linux, but fails on Windows. There is no system dependent code in this part of my code. It is solely on Go side.

@bradfitz
Copy link
Contributor

Yes, there are tests. And build.golang.org shows that it's passing.

The code in github.com/lxc/lxd is wrong. The error messages (they're not warnings; Go doesn't have warnings) you pasted above are the reason. I can't explain it any more clearly than the error messages already say.

@bradfitz
Copy link
Contributor

It doesn't even seem to compile on Linux!

$ go get github.com/lxc/lxd
# github.com/lxc/lxd/shared
../../../../../github.com/lxc/lxd/shared/util_linux.go: In function 'shiftowner':
../../../../../github.com/lxc/lxd/shared/util_linux.go:126:18: error: 'O_PATH' undeclared (first use in this function)
../../../../../github.com/lxc/lxd/shared/util_linux.go:126:18: note: each undeclared identifier is reported only once for each function it appears in

In any case, all you should have to do is change it to:

  if !terminal.IsTerminal(int(syscall.Stdin)) && value == "-" {

@techtonik
Copy link
Author

It can't be that it don't compile - test are green - https://github.com/lxc/lxd#ci-status Although I can't find where go get github.com/lxc/lxd is executed there.

@techtonik
Copy link
Author

@bradfitz it is strange that syscall.Stdin changes type on Windows. I expected types to be platform-independent, but thanks for this hint.

@bradfitz
Copy link
Contributor

In any case, this is the wrong bug tracker.

@techtonik
Copy link
Author

@bradfitz it is at least documentation bug in golang. According to https://golang.org/pkg/syscall/#pkg-variables syscall.Stdin should be int on all platforms. And for system-specific Windows calls, it could be made with syscall.StdinHandler or something.

@kostya-sh
Copy link
Contributor

@techtonik, golang.org/pkg displays documentation for Linux. Actually the additional documentation that you request is already there:

Package syscall contains an interface to the low-level operating system primitives. The details vary depending on the underlying system, and by default, godoc will display the syscall documentation for the current system. If you want godoc to display syscall documentation for another system, set $GOOS and $GOARCH to the desired system.

@techtonik
Copy link
Author

@kostya-sh thanks for clarification. Created issue. ;)

@golang golang locked and limited conversation to collaborators Oct 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants