From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: MPS: Win64 testers? Date: Tue, 06 Aug 2024 14:40:56 +0300 Message-ID: <86h6bxq3p3.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20344"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, pipcet@protonmail.com To: Quang Kien Nguyen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 06 13:41:48 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sbIZX-00055t-Of for ged-emacs-devel@m.gmane-mx.org; Tue, 06 Aug 2024 13:41:48 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbIZ8-0003VW-M3; Tue, 06 Aug 2024 07:41:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbIZ2-0003SA-6y for emacs-devel@gnu.org; Tue, 06 Aug 2024 07:41:16 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbIZ1-0005ei-Pm; Tue, 06 Aug 2024 07:41:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=thmcVgYPjezgAXlbGi62IhZQZLJNWtM6/A/wEFFg5iA=; b=FuGJEc23phM3 tigA1xy+iF0QXj7KzEFfNp3mqx1FpnTnURLUksgzY8+GNP/gHXGOq8+Na9gVAWanNJZrWZA8zUpPX HmvfMagL63sfWxbZvMNvjS3Sbq24wkFAVoI07xwqpXNYiMUvpimMFfhLg+ud2Rxsp1bM/6GI3Vwr4 xGsSznrFFfR39AAV/AQSbCDZAmkFu6FdMFl+Jx7qxdRTNWRLtmv8FbTctqcq2RC6hkHSGGkmopuy3 tpW+l4VRyAQ30dVAoAAPAo8mxappk9FMo9pURvLynk/QO2hNpMQOc1vGDbzc3BCBlP/QfbiL6E7vr IJS28vXktFCf3ksYccadFA==; In-Reply-To: (message from Quang Kien Nguyen on Mon, 5 Aug 2024 20:04:33 -0700) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:322438 Archived-At: > From: Quang Kien Nguyen > Date: Mon, 5 Aug 2024 20:04:33 -0700 > Cc: emacs-devel@gnu.org, pipcet@protonmail.com > > > > As for the code in question, if I understand it correctly, the current > > > Windows idiom would be simply (I assume _open_osfhandle clears the flag?): > > > > > > SetHandleInformation (GetStdHandle (STD_INPUT_HANDLE), HANDLE_FLAG_INHERIT, > > > 0); > > > > I'm not sure you can do this without closing the stream, since the > > program has already started by that time. And SetHandleInformation is > > only available since Windows 2K, so we'd need to call it through a > > function pointer. > I think using the SetHandleInformation here should be appropriate. > The implementation of _fdopen in ucrt is similar to Wine, it starts > looking from ` _IOB_ENTRIES` (== 3) stream. Here is the extracted source > code https://github.com/huangqinjin/ucrt/blob/master/stdio/stream.cpp#L12 > > So, once we close the `stdin/out/err`, there's noone who get assigned > back to those streams, and then the final close in `sys_dep.c` will fail > for UCRT. > > I have tested with my own UCRT64 build of Emacs at > https://github.com/kiennq/emacs-build/releases/tag/v31.276.20240805.2332f50, > With the patch of > https://github.com/kiennq/emacs-build/edit/main/patches/0001-init_winntproc-Use-SetHandleInformation-to-set-NOINH.patch > > The SetHandleInformation returns no error even without streams being > closed. Thanks, noted. What we need next is (a) a clean patch, and (b) thorough testing that the standard handles are indeed not inherited by sub-processes of Emacs when the patch is applied.