emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MPS: Win64 testers?


From: Quang Kien Nguyen
Subject: Re: MPS: Win64 testers?
Date: Tue, 6 Aug 2024 00:03:45 -0700


> > 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]