winpty icon indicating copy to clipboard operation
winpty copied to clipboard

Use Microsoft’s new ConPTY API on Windows versions which support it (i.e. Fall 2018 and newer)

Open ExE-Boss opened this issue 5 years ago • 11 comments

https://blogs.msdn.microsoft.com/commandline/2018/08/02/windows-command-line-introducing-the-windows-pseudo-console-conpty/

As winpty is one of the most commonly used PTY implementations in Windows programs which need PTY functionality, to reduce work for third parties which rely on winpty, it would be a good idea if the winpty library would simply become a translation layer on Windows 10 Fall 2018 update and newer by using the ConPTY detection mechanism outlined in the linked article.


Related: Microsoft/node-pty#216

ExE-Boss avatar Aug 19 '18 18:08 ExE-Boss

There should probably be a layer somewhere that chooses between ConPTY and winpty's current agent-based scraping. It could make sense to just put that layer in winpty itself. I'll try to work on this sometime.

rprichard avatar Aug 20 '18 18:08 rprichard

There should probably be a layer somewhere that chooses between ConPTY and winpty's current agent-based scraping.

Yes this is the strategy I'm using for node in https://github.com/Microsoft/node-pty/issues/216, I'll detect the feature set and either run conpty or fallback to winpty.

Tyriar avatar Aug 23 '18 18:08 Tyriar

@rprichard Lemme know if you need any help adding support for conpty, or if you find any bugs or gaps in functionality. I'm happy to help in any way I can :)

zadjii-msft avatar Oct 15 '18 21:10 zadjii-msft

Hi,

My two cents about this:

  • Some programs (or several) use the CygTerm mode to interact with the Cygwin console Apps. The basis it's the cthelper.exe process.
  • As the new Win10 ConAPI support PTY for any Windows/WSL console Apps, now it's possible to execute all Cygwin/SSH/Win32/WSL console Apps inside the WSL Bash shell.
  • Then, you can prepare a "simple" modification of the cthelper.exe that runs win the WSL BASH SHELL, instead of the CygWin BASH (or with any other native Win10 shell).
  • And with this change any program that has support for the CygTerm CTHELPER will obtain console support.

So, in summary: Why not create a new cthelper-wsl.exe?

What you think?

lars18th avatar Oct 16 '18 14:10 lars18th

I'd like to add, that testing if api functions present isn't sufficient, new console could be disabled in settings ("Use legacy console") by windows admin user. For compatibility I guess.

Need to check about this option.

Mart-Bogdan avatar Mar 03 '19 20:03 Mart-Bogdan

@rprichard Do you plan to implement it in winpty?

segrey avatar Apr 04 '19 20:04 segrey

@rprichard are you still maintaining this or is there an alternative?

Stanzilla avatar May 04 '20 13:05 Stanzilla

What's the reason for using winpty if ConPTY is available, though? From what I can see, it provides a similar interface by itself.

ForNeVeR avatar Sep 06 '21 07:09 ForNeVeR

@ForNeVeR support for Windows before Windows 10

Tyriar avatar Sep 06 '21 14:09 Tyriar

Just curious - do you know of or assume large amount of pre-Windows 10 installations? Win 11 is knocking on the door, so I'm not sure this will be that important soon.

dumblob avatar Sep 22 '21 09:09 dumblob

Cygwin itself now supports ConPTY (it is disabled in MSYS2 by default, though). Supporting it in winpty might not be so important.

k-takata avatar Sep 22 '21 10:09 k-takata