pty icon indicating copy to clipboard operation
pty copied to clipboard

Another attempt of support pty on windows with ConPTY api

Open photostorm opened this issue 3 years ago • 75 comments

This is an another attempt to support pseudo-terminal on windows using ConPty API (should resolve issue https://github.com/creack/pty/issues/95)

This pull request does introduce major api change for Start method (*os.File -> Pty),

I have tested this code with remote terminal application that I wrote. It would be great to get some additional testing with other use cases.

photostorm avatar Jul 25 '22 22:07 photostorm

This looks very promising, I will try it out to see if it works in our system

pete-woods avatar Jul 27 '22 10:07 pete-woods

I just tried this out, and works perfectly for my use case (an SSH server that must work on UNIX and Windows) 👍

pete-woods avatar Jul 27 '22 14:07 pete-woods

Trying this now. Would be really nice if this works on go 1.18 too :) considering repo is still pointing to 1.13 :D

mjudeikis avatar Jul 28 '22 15:07 mjudeikis

It worked on Go 1.18 for me

pete-woods avatar Jul 28 '22 16:07 pete-woods

It just passed our ci too. Worked like a charm too :)

On Thu, Jul 28, 2022, 7:49 PM Pete Woods @.***> wrote:

It worked on Go 1.18 for me

— Reply to this email directly, view it on GitHub https://github.com/creack/pty/pull/155#issuecomment-1198395129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYTREGNBTBOT5HCXFTO3ATVWK23LANCNFSM54T43GUQ . You are receiving this because you commented.Message ID: @.***>

mjudeikis avatar Jul 28 '22 16:07 mjudeikis

@creack if you have time to look at this, it would be most appreciated, I found the API break to be extremely unintrusive (in that I didn't need to change any code)

pete-woods avatar Jul 28 '22 16:07 pete-woods

I’ll take a look over the weekend. Quite a few tickets in backlog, sorry about that.

On Thu, Jul 28, 2022 at 10:51 AM Pete Woods @.***> wrote:

@CrEaK https://github.com/CrEaK if you have time to look at this, it would be most appreciated, I found the API break to be extremely unintrusive (in that I didn't need to change any code)

— Reply to this email directly, view it on GitHub https://github.com/creack/pty/pull/155#issuecomment-1198396721, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD7LZMFPY36MECEUL42SDDVWK3CBANCNFSM54T43GUQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

Guillaume J. Charmes

creack avatar Jul 28 '22 16:07 creack

minions-please

pete-woods avatar Aug 11 '22 13:08 pete-woods

image Please help to remove wild forks!

mjudeikis avatar Aug 11 '22 13:08 mjudeikis

Worked for me on 1.18 and 1.17.1, thanks @photostorm 👏👏👏

gabemarshall avatar Sep 27 '22 14:09 gabemarshall

@creack Is there anything we can do to help with this PR getting reviewed? Windows support is a really big deal for a bunch of users of your library.

pete-woods avatar Oct 03 '22 10:10 pete-woods

I'm happy this PR exists. However, it introduces a breaking change: *os.File -> Pty. The func Start and StartWithAttrs return *os.File currently, but the PR changes this to type Pty.

mohammed90 avatar Oct 22 '22 21:10 mohammed90

FWIW I agree there should be a high bar to justify incompatible changes to the interface. It's not immediately clear to me why that would be necessary to add Windows support.

kr avatar Oct 23 '22 03:10 kr

There should be high bar to justify incompatible changes to the interface. Due to the return type of Start, I do not see a way to pass the handles. I think this API change would make it possible for other systems in future to be added.

photostorm avatar Oct 24 '22 16:10 photostorm

Would it be possible to use a Unix socket on Windows instead of a pair of pipes? Each end of a socket is full-duplex, which might mean the exported interface can be a single os.File object.

https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/

kr avatar Oct 24 '22 18:10 kr

ok, I will look into it. Thanks for your feedback. @kr

photostorm avatar Oct 24 '22 19:10 photostorm

@kr I do not think I can used that. there is window handle that I need access to also.

photostorm avatar Oct 26 '22 01:10 photostorm

Ultimately we will have to defer to @creack, it's his library.

My feeling is, it might be worth breaking the API, if that's absolutely necessary to support Windows. Even in that case, I think any new interface should undergo careful design review (which I could participate in).

But we haven't exhausted all the strategies to maintain compatibility. For instance, maybe the window handle could be stored on the side in a global lookup table, and the *os.File pointer or a file descriptor or something could be used to look up the window handle when it's needed.

var (
	windowHandles = map[*os.File]windows.Handle{}
	windowHandlesMu sync.Mutex
)

Choosing a suitable value to use as the map key could be tricky. The fd might not work if the client code calls dup or something. I don't have great knowledge of the Windows API and its semantics so I don't know offhand if there's a good value to use. Is there a stable way to identify a pty in Windows? Maybe something available via os.FileInfo.Sys?

Also, this would probably need to use a finalizer to delete map entries.

What do you think?

kr avatar Oct 26 '22 02:10 kr

That seems like a plausible strategy to me, but without input from @creack I don't thing we can realistically progress

pete-woods avatar Feb 01 '23 20:02 pete-woods

@creack have you gotten the chance to review this PR? My team could definitely use this. At the moment we are relying on @photostorm's fork (which has worked perfectly so far)

sabattle avatar Feb 21 '23 18:02 sabattle

@creack It would be deeply appreciated if this PR could be merged 🙏🏼

tflpd avatar Mar 09 '23 00:03 tflpd

The code looks good! really hoping this gets merged. This will help my project so much!

ekam-g avatar May 18 '23 20:05 ekam-g

Seems like the author has abandoned the project, maybe it's better to create another fork?

charliie-dev avatar Jun 08 '23 02:06 charliie-dev

I am still around, but indeed real life has been on the way lately. I have quite a lot of pry pr/issues pinned, I’ll address them as soon as I can. This kind of thing require quite a lot of time.

On Wed, Jun 7, 2023 at 10:50 PM Charles Chiu @.***> wrote:

Seems like the author has abandoned the project, maybe it's better to create another fork?

— Reply to this email directly, view it on GitHub https://github.com/creack/pty/pull/155#issuecomment-1581808414, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD7LZOSHUEFIYWVM2JYF2LXKE4Y3ANCNFSM54T43GUQ . You are receiving this because you were mentioned.Message ID: @.***>

--

Guillaume J. Charmes

creack avatar Jun 08 '23 11:06 creack

tks for the reply!

charliie-dev avatar Jun 08 '23 11:06 charliie-dev

looking forward to get this merged!

a-urth avatar Jun 30 '23 13:06 a-urth

Any news on this pull request?

aropele avatar Aug 23 '23 09:08 aropele

@photostorm ~since this PR has yet to be merged (eagerly awaiting the day!) and since your repo has issues turned off the best place I can think to report an issue is on this thread.~

Contents of comment moved: https://github.com/photostorm/pty/issues/2

Naatan avatar Aug 31 '23 21:08 Naatan

@Naatan They should be open now.

photostorm avatar Aug 31 '23 21:08 photostorm

@photostorm thanks! Opened a ticket on your repo instead 🙏

Naatan avatar Aug 31 '23 21:08 Naatan