Hi Corinna, Thanks for the comment.
On Thu, 4 Dec 2025 12:01:58 +0100 Corinna Vinschen wrote: > On Dec 3 17:56, Takashi Yano via Cygwin wrote: > > Subject: [PATCH v2] Cygwin: pty: Experimental OpenConsole.exe support > > Some commit message here? Yeah, I know, it's just experimental for now :) > > > Signed-off-by: Takashi Yano <[email protected]> > > --- > > winsup/cygwin/fhandler/pty.cc | 281 ++++++++++++++++++++++++++++++---- > > 1 file changed, 251 insertions(+), 30 deletions(-) > > > > diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc > > index 679068ea2..2c9af1742 100644 > > --- a/winsup/cygwin/fhandler/pty.cc > > +++ b/winsup/cygwin/fhandler/pty.cc > > @@ -33,6 +33,136 @@ details. */ > > #define PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE 0x00020016 > > #endif /* PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE */ > > > > +static NTSTATUS > > +create_handle (PHANDLE handle, PCWSTR device_name, > > + ACCESS_MASK desired_access, HANDLE parent, > > + BOOLEAN inheritable, ULONG open_options) > > +{ > > + ULONG flags = OBJ_CASE_INSENSITIVE; > > + if (inheritable) > > + flags |= OBJ_INHERIT; > > + > > + UNICODE_STRING name; > > + RtlInitUnicodeString (&name, device_name); > > + > > + OBJECT_ATTRIBUTES object_attributes; > > + InitializeObjectAttributes (&object_attributes, &name, flags, parent, > > NULL); > > + > > + IO_STATUS_BLOCK io; > > + return NtOpenFile (handle, desired_access, &object_attributes, &io, > > + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, > > + open_options); > > +} > > + > > +extern "C" WINBASEAPI HRESULT WINAPI > > +CreatePseudoConsole_new (COORD size, HANDLE h_input, HANDLE h_output, > > + DWORD flags, HPCON *hpcon) > > +{ > > I'm actually surprised that Cygwin should implement its own > CreatePseudoConsole instead of just trying to call into conpty.dll. > If you think this is the right thing to do, ok with me. I did that just because it looks easier than build conpty.dll from source because conpty.dll depends on WIL. > But then, this code is basically by courtesy of the terminal code on > github. It would be prudent to add a comment preceding the code > explaining where the algorithm is coming from and copying the MIT > license. Note that attribution is part of the MIT license: > https://opensource.org/license/mit Will do. > > + status = create_handle (&h_con_reference, L"\\Reference", > > I would rename the function a bit to make clear this is only for the local > creation of the pseudo console handles. Sth like create_console_handle or > create_pconsole_hdl, perhaps. OK. > > @@ -2136,6 +2266,8 @@ fhandler_pty_master::close (int flag) > > ssize_t > > fhandler_pty_master::write (const void *ptr, size_t len) > > { > > Aren't from here on two patches folded into one? All but one hunk (the > one calling CreatePseudoConsole_new) seem to be entirely independent of > OpenConsole. This part is necessary to work with OpenConsle.exe. OpenConsole.exe uses also ESC[c during startup while conhost.exe uses only ESC[6n. > It would be nice to get a commit message explaining the changes and > source comments explaining the new code wouldn't hurt either. > > > + size_t towrite = len; > > + > > ssize_t ret; > > char *p = (char *) ptr; > > termios &ti = tc ()->ti; > > @@ -2152,7 +2284,7 @@ fhandler_pty_master::write (const void *ptr, size_t > > len) > > If the reply for "CSI6n" is divided into multiple writes, > > pseudo console sometimes does not recognize it. Therefore, > > put them together into wpbuf and write all at once. */ > > - static const int wpbuf_len = strlen ("\033[32768;32868R"); > > + static const int wpbuf_len = 64; /* for response to CSI6n nad CSIc */ > > Is there some macro for the count of 64 in this context, by any chance? I'm not sure for now that 64 is really enough for the responce to ESC[c. mintty returns about 30 byte responce. But some other terminal may return longer responce. > > [...] > > if [ $(uname -m) = "x86_64" ] > > then > > POSTFIX="x64" > > else > > POSTFIX="x86" > > Do we really want a 32 bit version? Isn't there an aarch64 version? No. What should we assume result of "uname -m" in aarch64 machine? > > VERSION=$(cat /etc/libopenconsole/version.txt) > > cd /tmp > > wget -q > > https://github.com/microsoft/terminal/releases/download/v${VERSION}/Microsoft.WindowsTerminal_${VERSION}_${POSTFIX}.zip > > -O - > Microsoft.WindowsTerminal_${VERSION}_${POSTFIX}.tmp > > For a start, this may be ok, but we should really try to build our own > OpenConsole package build by our own gcc or clang, IMHO. OpenConsole.exe also uses WIL, so it looks not easy to build it in cygwin environment. Maybe just getting it from https://github.com/microsoft/wil/ is enough, but I have not tried it yet. -- Takashi Yano <[email protected]> -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple

