From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Quang Kien Nguyen Newsgroups: gmane.emacs.devel Subject: Re: MPS: Win64 testers? Date: Mon, 5 Aug 2024 20:04:33 -0700 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000053c3c6061efb0e02" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5849"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, pipcet@protonmail.com To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 06 13:00:26 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 1sbHvV-0001Mx-ES for ged-emacs-devel@m.gmane-mx.org; Tue, 06 Aug 2024 13:00:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbHvF-0008MO-Pr; Tue, 06 Aug 2024 07:00:10 -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 1sbAVI-0001fd-Hb for emacs-devel@gnu.org; Mon, 05 Aug 2024 23:04:52 -0400 Original-Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sbAVG-0003Yu-8J; Mon, 05 Aug 2024 23:04:52 -0400 Original-Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5a108354819so189238a12.0; Mon, 05 Aug 2024 20:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722913487; x=1723518287; darn=gnu.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=GSu73pw2OWv0kZU0emArFwjY13+HUCR0K11iLw27fXg=; b=kPIkRt36omHg8dzc0kifhyhdZwbCz7qy6keSxvvFP4lgsnpP2w8MKxBQku476jKmhs aZonRj/A11O++QC82TUhImZY9fthUPpTdlpsR7Jjrdz2paxuryVkMwdkpnJITghAijHK D3BwBucohBR4WzHjsS9m7RkaCj+rQcmoIZ/I/4x5kNbh8xuj/aajVohOjfs6FDwgzgyt duzR3NjB8DPP8F07vekgTkQr3eUMBbk+mROJRaabt44t2OALRIpK7DMP0tnh0CAyUOaN Q2IifWHiAbFoJ1wiHqGhaylMg3kOOSAkYzfa/vhsLJqDzH8eEv2ro9b6rIEDoWCTm6bv HF7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722913487; x=1723518287; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=GSu73pw2OWv0kZU0emArFwjY13+HUCR0K11iLw27fXg=; b=tcSOcxsXbU5RFr/b7icKsc67rcdS0oLLipZDHeZU4v7OM4/G3mfqK1LYO60kK8pxT8 p+2ebuh8RESN0GCWq3Nc+f2TsaMFjDKcXJ6pr1d6qkE0vNCzbIKtaOL89NfH7m7cn+oa q1RpI7n90csJ1tJ1lA5GMpnXJy2vez0cyT8JvuGT8xNtj6l+n6FLh1JdqDxiuk5CzbYz /8ECUXbVgb/fYJUGhsOeJCZJYCyVpomT5ayJyx6zMPUZcCtePLwu0Vt9WmvFQ7QPlTi9 I33dAlElKJXxTNG68ASizxHvWi1+xbHAh7fKZDt/KViYPjrRRsE6asSq2jhfZZ099bR0 5kyQ== X-Gm-Message-State: AOJu0Yy0snW7QNxZ0LK3iE2I1ICEyEf2w9Ms2fqiTSf1b1fUIIJLk5Jb 3oxELoRuJOhk7qjPvAT7mxgzJxOh9HhHWULeb2AGPaf/saCA84sSnJQk3+aNLkcChFrQTefD4Ke Xyp3yFo6Ee/VLsvDg3jg3pKBLsqLoQFEa X-Google-Smtp-Source: AGHT+IEFTMQ4FpJn7vLd8/XtL1k2EbdNLgI7uZ7nPgq6kH9UNSjM+OVzPBYqj5rTOLsiUnAtpSn88PHStSsbUzruvRY= X-Received: by 2002:a17:907:7f24:b0:a7d:a29e:5c41 with SMTP id a640c23a62f3a-a7dc5029a1dmr994626766b.40.1722913486257; Mon, 05 Aug 2024 20:04:46 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=kien.n.quang@gmail.com; helo=mail-ed1-x530.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 06 Aug 2024 06:59:52 -0400 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:322431 Archived-At: --00000000000053c3c6061efb0e02 Content-Type: text/plain; charset="UTF-8" > > 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. --- Kien --00000000000053c3c6061efb0e02 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> > As for the code =
in question, if I understand it correctly, the current 
> > Window= s idiom would be simply (I assume _open_osfhandle clears the flag?):
>= ; >
> > SetHandleInformation (GetStdHandle (STD_INPUT_HANDLE),= HANDLE_FLAG_INHERIT,
> > 0);
>
> I'm not sure y= ou can do this without closing the stream, since the
> program has al= ready started by that time. And SetHandleInformation is
> only availa= ble since Windows 2K, so we'd need to call it through a
> functio= n pointer.
I think using the SetHandleInformation here should be appropr= iate.
The implementation of _fdopen in ucrt is similar to Wine, it start= s
looking from ` _IOB_ENTRIES` (=3D=3D 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 UCR= T64 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 ev= en without streams being
closed.

---
Kien
--00000000000053c3c6061efb0e02--