DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 5B59qnIH1228654 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 5B59qnIH1228654 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=QGCgibl/ X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E42E84C31884 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1764928367; bh=EVlMcFbBV4iYtau+ttIo54gh8eHYaa2aDRXPthfH+Mo=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=QGCgibl/msgWHuteKpyuSfqQmgWDiavBg9YE9C3+g1mKeBaon932lPfaEK7X/wjFB y8aPrCnLXtVkVSn5XAdEKK/JbPdA5HaeYcBkpccHWRvhae/p4FRBzGsaLk9563APUJ WeS25xNmaglvDdeRnkbhwinANg/AlYAiNw9boCvI= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 092974BB3BC8 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 092974BB3BC8 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1764928345; cv=none; b=XetEZsui1MHkvTv0VZa88kJntuQoZfkbVcB0g9x8gOGpWOuNOxfQZaWdcGeiISK/Tzw30+ZQm7vNOs8KdOmtybtwJhXpInomhnkofp05hlM/iHnt1AUJdPi+Rn/Fd+dT+KM5OpswWzyDtJApGBVff7hId2NHz7aKIG/N/AV+x0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1764928345; c=relaxed/simple; bh=YJQimL+To1wvKqYFOR/WfE8f+BAxS1zjd9m0RWVwI5M=; h=Date:From:To:Subject:Message-Id:Mime-Version:DKIM-Signature; b=s5a0D7cRBLyrAKBw3/SyDPBlWdvvh5ypd9zMk7+VRoZ+ibYcis/PSUyzUGGpEPQkHwUlfbydtNbgjYi4ucP7gBERm6Gryc6pL3oq+tU54VBHJUFwtxAZOJZozdraLRIcRj/8AW+Sfom7t91Fx50IFWZdoSfM5pMR2bTaMHguaIg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 092974BB3BC8 Date: Fri, 5 Dec 2025 18:52:20 +0900 To: cygwin AT cygwin DOT com Subject: Re: dynamic conpty loading Message-Id: <20251205185220.26512b609b7e96b388245244@nifty.ne.jp> In-Reply-To: References: <30deef29-ba20-49d9-9b38-28020941b0ef AT towo DOT net> <707f4d4c-a20d-4f1d-bdbd-65a2392dea15 AT towo DOT net> <20251121190433 DOT 4a37dc959848a0aea89a8922 AT nifty DOT ne DOT jp> <62f3c1ae-1fd9-477d-a837-d865094dab06 AT towo DOT net> <20251126193220 DOT 1b890f58a121add2f0d05fa5 AT nifty DOT ne DOT jp> <3a6ed5bc-24fd-42b0-9f57-83c8eb678a1b AT towo DOT net> <20251127172026 DOT 6b6f876fd341f9c0cbd1f876 AT nifty DOT ne DOT jp> <20251203175638 DOT 0b4f51242c8fdab685ad9b7e AT nifty DOT ne DOT jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Takashi Yano via Cygwin Reply-To: Takashi Yano Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" 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 > > --- > > 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 -- 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