Skip to content

Replace ConhostConnection with ConptyConnection#3461

Merged
DHowett-MSFT merged 5 commits intomasterfrom
dev/duhowett/die_conhostconnection_ist
Nov 6, 2019
Merged

Replace ConhostConnection with ConptyConnection#3461
DHowett-MSFT merged 5 commits intomasterfrom
dev/duhowett/die_conhostconnection_ist

Conversation

@DHowett-MSFT
Copy link
Contributor

This commit deletes ConhostConnection and replaces it with
ConptyConnection. The ConptyConnection uses CreatePseudoConsole and
depends on winconpty to override the one from kernel32.

  • winconpty must be packageable, so I've added GetPackagingOutputs.
    • To validate this, I added conpty.dll to the MSIX regression script.
  • I moved the code from conpty-universal that deals with environment
    strings into the types library.

This puts us in a way better place to implement #2563, as we can now
separately detect a failure to launch a pseudoconsole, a failure to
CreateProcess, and a failure of the launched process.

Fixes #1131.

References

Relevant to #2563.

PR Checklist

Validation Steps Performed

Launched WT a bunch, with shells and pseudoterminal hosts that didn't exist, and killed various processes all over the tree.

@DHowett-MSFT
Copy link
Contributor Author

There's an argument to be made that I should be using the modern threadpooling APIs, but.. that would require us to have a shared threadpool onto which all work gets dispatched instead of letting the system manage one for us. Why would we not want the system to manage one for us?

@miniksa
Copy link
Member

miniksa commented Nov 6, 2019

There's an argument to be made that I should be using the modern threadpooling APIs, but.. that would require us to have a shared threadpool onto which all work gets dispatched instead of letting the system manage one for us. Why would we not want the system to manage one for us?

Per offline discussion, plx try it.

@DHowett-MSFT
Copy link
Contributor Author

Done, and fixed SA too.

@DHowett-MSFT DHowett-MSFT force-pushed the dev/duhowett/die_conhostconnection_ist branch from 932775a to 8bde4c2 Compare November 6, 2019 18:36
This commit deletes ConhostConnection and replaces it with
ConptyConnection. The ConptyConnection uses CreatePseudoConsole and
depends on winconpty to override the one from kernel32.

* winconpty must be packagebale, so I've added GetPackagingOutputs.
   * To validate this, I added conpty.dll to the MSIX regression script.
* I moved the code from conpty-universal that deals with environment
  strings into the types library.

This puts us in a way better place to implement #2563, as we can now
separately detect a failure to launch a pseudoconsole, a failure to
CreateProcess, and a failure of the launched process.

Fixes #1131.
@DHowett-MSFT DHowett-MSFT force-pushed the dev/duhowett/die_conhostconnection_ist branch from 8bde4c2 to 01a146f Compare November 6, 2019 18:40
@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Nov 6, 2019
Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

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

Yep.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

this is neat

Co-Authored-By: Mike Griese <[email protected]>
@DHowett-MSFT
Copy link
Contributor Author

I am using my admin powers because 1. the only change was in a comment and 2. code formatter phase passed

@DHowett-MSFT DHowett-MSFT merged commit 357e835 into master Nov 6, 2019
@DHowett-MSFT DHowett-MSFT deleted the dev/duhowett/die_conhostconnection_ist branch November 6, 2019 23:09
@DHowett-MSFT
Copy link
Contributor Author

 build/scripts/Test-WindowsTerminalPackage.ps1      |   4 +
 .../CascadiaPackage/CascadiaPackage.wapproj        |   7 +-
 src/cascadia/TerminalApp/TerminalPage.cpp          |  12 +-
 .../TerminalConnection/ConhostConnection.cpp       | 238 -----------
 .../TerminalConnection/ConhostConnection.h         |  58 ---
 .../TerminalConnection/ConhostConnection.idl       |  15 -
 .../TerminalConnection/ConptyConnection.cpp        | 437 ++++++++++++---------
 src/cascadia/TerminalConnection/ConptyConnection.h |  47 ++-
 .../TerminalConnection/ConptyConnection.idl        |   3 +-
 .../TerminalConnection/TerminalConnection.vcxproj  |  21 +-
 .../TerminalConnection.vcxproj.filters             |   5 +-
 src/common.build.pre.props                         |   4 +
 src/inc/conpty-universal.h                         | 358 -----------------
 src/types/Environment.cpp                          | 132 +++++++
 src/types/inc/Environment.hpp                      |  31 ++
 src/types/lib/types.vcxproj                        |   2 +
 src/winconpty/winconpty.vcxproj                    |  38 +-
 17 files changed, 523 insertions(+), 889 deletions(-)

889 deletions is pretty good.

DHowett-MSFT pushed a commit that referenced this pull request Nov 7, 2019
This also sets up TerminalConnection to _have_ resources, which will be useful for the messages in #3461.
@ghost
Copy link

ghost commented Nov 26, 2019

🎉Windows Terminal Preview v0.7.3291.0 has been released which incorporates this pull request.:tada:

Handy links:

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.

Switch from ConhostConnection to the official ConPTY API

4 participants