microsoft/Terminal

CreatePseudoConsole doesn't handle sockets correctly

Open

#4,359 建立於 2020年1月26日

在 GitHub 查看
 (6 留言) (0 反應) (0 負責人)C++ (3,212 fork)batch import
Area-QualityHelp WantedIssue-BugPriority-1Product-Conpty

倉庫指標

Star
 (35,764 star)
PR 合併指標
 (平均合併 27天 19小時) (30 天內合併 24 個 PR)

描述

The documentation of CreatePseudoConsole explicitly documents that CreatePseudoConsole can be used with sockets:

https://docs.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session#preparing-the-communication-channels

If we look at the implementation of CreatePseudoConsole, we can see it calls DuplicateHandle on the handles passed to it:

https://github.com/microsoft/terminal/blob/2712e41cad2abcfe627934e41e713ea132a659de/src/winconpty/winconpty.cpp#L348-L349

However, the documentation of DuplicateHandle explicitly mentions that DuplicateHandle should not be used to duplicate socket handles:

https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-duplicatehandle#remarks

Doesn't this make the CreatePseudoConsole implementation incorrect when using sockets?

I haven't actually confirmed whether sockets work or not, I'm currently trying to get CreatePseudoConsole to work with sockets but it's returning Access is Denied. While looking at the source code to figure out why it's returning Access is Denied, I stumbled upon this possible issue.

EDIT: Nvm the Access is Denied issue, I incorrectly assumed CreatePseudoConsole would return 0 on failure. The DuplicateHandle issue still stands however.

EDIT2: Removed edit because it was a programming error by me.

貢獻者指南