bgentry / speakeasy

cross-platform Golang helpers for reading password input without cgo
Other
116 stars 24 forks source link

[Windows/mintty] The handle is invalid #7

Closed THUNDERGROOVE closed 6 years ago

THUNDERGROOVE commented 9 years ago

On Windows 8.1 I'm getting a "The handle is invalid" error while attempting to call Ask.

bgentry commented 9 years ago

Hi @THUNDERGROOVE. I'm sorry you ran into an issue here. Unfortunately, I don't have access to a copy of Windows 8.1 to try this with, and there's not really for me to go on with that error message. Please do let me know if you find any sort of solution to this!

THUNDERGROOVE commented 9 years ago

I've found the issue. The application I was working on needed some cgo stuff, so I was using msys2. The terminal it ships with, mintty, doesn't handle the windows calls.

Looks like stty works in mintty. Do you think it would be worth supporting this? I'm not sure of a way to get the name of the process that call us to check if it was mintty.exe. Using ps would work but if you have a mintty shell and another prompt it'll still report it being open.

If getting the terminals process name isn't reliable/possible, we could maybe check if we got an invalid handle error and fallback to stty? The problem with this is that this would fail silently which is pretty awful.

MichaelS11 commented 9 years ago

Wanted to mention that the same issue happens when using Eclipse.

Seems to be a problem in other languages as well, for example:

http://stackoverflow.com/questions/15668607/getpass-echoing-password-in-eclipse