A question (not an issue) about ConPTY feature. #358

Open
opened 2026-01-30 21:49:55 +00:00 by claunia · 0 comments
Owner

Originally created by @HBelusca on GitHub (Aug 30, 2018).

Hello and sorry for hijaking the "issues" thread for just asking a question about the new ConPTY feature.

On *nix, the openpty() function returns file descriptors to the PTY device, one descriptor for the PTY master (used by the terminal emulator), and one descriptor for the PTY slave (that is dup'ed for the console app that will be connected to the terminal). One can understand the descriptors as "handles" to the PTY channels.

However in the new Windows' ConPTY api, the CreatePseudoConsole() function takes as INPUT handles to (pre-created) in- and out- pipes that will basically play together the role of PTY master side, for input and output.
What I don't completely understand, is why it has been done like this, instead of having a function that retrieves handles for us (so, it would return HANDLEs by pointer), i.e. really "open" a PTY (note that we would then need to provide an optional LPSECURITY_ATTRIBUTES in that scenario).
Also, why wouldn't this (these?) handles be instead handles to the pseudo-files maintained by the condrv driver? (e.g. handle to some \Device\ConDrv\ScreenBuffer or Display? or to something else): This would allow the condrv driver to really act as the (kernel-mode side of) PTY driver (the user-mode side is conhost and is connected to the console app being run).

Originally created by @HBelusca on GitHub (Aug 30, 2018). Hello and sorry for hijaking the "issues" thread for just asking a question about the new ConPTY feature. On *nix, the `openpty()` function **returns** file descriptors to the PTY device, one descriptor for the PTY master (used by the terminal emulator), and one descriptor for the PTY slave (that is dup'ed for the console app that will be connected to the terminal). One can understand the descriptors as "handles" to the PTY channels. However in the new Windows' ConPTY api, the `CreatePseudoConsole()` function takes as **INPUT** handles to (pre-created) in- and out- pipes that will basically play together the role of PTY master side, for input and output. What I don't completely understand, is why it has been done like this, instead of having a function that retrieves handles for us (so, it would return HANDLEs by pointer), i.e. really "open" a PTY (note that we would then need to provide an optional LPSECURITY_ATTRIBUTES in that scenario). Also, why wouldn't this (these?) handles be instead handles to the pseudo-files maintained by the condrv driver? (e.g. handle to some \Device\ConDrv\ScreenBuffer or Display? or to something else): This would allow the condrv driver to really act as the (kernel-mode side of) PTY driver (the user-mode side is conhost and is connected to the console app being run).
claunia added the Issue-QuestionProduct-Conpty labels 2026-01-30 21:49:55 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#358