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: Tue, 6 Aug 2024 00:03:45 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000b230f6061efe6546" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8867"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 06 13:01:02 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 1sbHw6-0002B8-7D for ged-emacs-devel@m.gmane-mx.org; Tue, 06 Aug 2024 13:01:02 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbHvG-0008Ow-De; 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 1sbEEk-0004JT-OQ for emacs-devel@gnu.org; Tue, 06 Aug 2024 03:04:02 -0400 Original-Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sbEEi-0000Sl-Rn for emacs-devel@gnu.org; Tue, 06 Aug 2024 03:04:02 -0400 Original-Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5a79df5af51so10768581a12.0 for ; Tue, 06 Aug 2024 00:04:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722927837; x=1723532637; darn=gnu.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=H9E4OzlNDfugvFHrKIHiM0j1/o0pkzFwuShxESC1PiQ=; b=WeNFt80aNLSEBIhZ9VCjxKlR2XrqaVXitF2cH77s9u5pRC2m1G0MdzJcP7TT+LUBxn O2faT3lMWtDHMY7moenlq7/a2jURaeTcFrtEbvn1DUrAcx5TGNzbAlbEQuXamtgU6Y28 ntpjhdFz9/IYBMQ8jeDuzzinIH7zGJzT1u4UzbeeWKAAKZKyot3TsIziy1aBH1PNhowP nc4yHT9TbCHiv8UzAy2DB/WzoDDIqpx+fgl6ogHXon5+mqxWMKHh3+Ul4lm5KbYdFy9j H/XYE6dE5N/Eo1+dsWKKUMTUKQRkKALMbUgjTTH9CPwJYqaM33/qbc+4T20dIL2P+ctq xm9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722927837; x=1723532637; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=H9E4OzlNDfugvFHrKIHiM0j1/o0pkzFwuShxESC1PiQ=; b=RvY5LLROw/a8gViOK3ZG01KujeXHKTY8aUWd0cCWTyI0zVm/xRMUZzZ17KwDltTN65 +W/9VMjYWLx3GRIo8v0l60MMXsPwYHnq2WLOmkT/L8cXfs37NejeTd8nUVetgQWWkvzj tjCX1EooOmpJxCPJC4pm6swP63qUxWoiMd4XgUTfaLyzYT1KxdKzidlvPHN+y/JQthns ZI9QnpESrunFvPFASCVORXuIu0/YQo5sjk+VixjJyiXHtue+ZI8cOmv5LfZefPP4qQRp FtKT85g02TMM2RvHOUb3tzUkU7qPfUMEMD2vJFFLYvZMzT7mjjlav0kUXeQ6mcZFYsa/ ayPA== X-Gm-Message-State: AOJu0YxlTGUkSaVenpMSOIpNSrQuUKsqSbvdAGiSWGB6EXGlLeVDl5pK zEQaeSxZE+OsKVop9eUrL+I8HjPF3WukfdUcp+lqxQFL/shCvNzvJQPDjoSNwNU8dRkE+vBeRgb tAp2fdybByXhVbZv1+xI3MSVGQJZ1Kg== X-Google-Smtp-Source: AGHT+IFiVTSzJsSRo0dE1HYVUxK1QbD0JgQfyGBhz/2Jc7UmYIZe7NRjEsqiJJ9yr3EvdnzYkn7XI2oquLS8p50sImM= X-Received: by 2002:a17:907:9406:b0:a7a:952b:95cf with SMTP id a640c23a62f3a-a7dbe66cc25mr1215846166b.32.1722927836965; Tue, 06 Aug 2024 00:03:56 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=kien.n.quang@gmail.com; helo=mail-ed1-x531.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:56 -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:322432 Archived-At: --000000000000b230f6061efe6546 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 --000000000000b230f6061efe6546 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

> > As for the code in qu= estion, if I understand it correctly, the current=C2=A0
> > Windows idiom would=
 be simply (I assume _open_osfhandle clears the flag?):
> >
&g= t; > SetHandleInformation (GetStdHandle (STD_INPUT_HANDLE), HANDLE_FLAG_= INHERIT,
> > 0);
>
> I'm not sure you can do thi= s without closing the stream, since the
> program has already started= by that time. And SetHandleInformation is
> only available since Win= dows 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` (=3D=3D 3) stream. Here is the extracted source
cod= e https://github.com/huangqinjin/ucrt/blob/master/s= tdio/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 ow= n 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/000= 1-init_winntproc-Use-SetHandleInformation-to-set-NOINH.patch

The= SetHandleInformation returns no error even without streams being
closed= .

---
Kien
--000000000000b230f6061efe6546--