; * src/w32.c (init_ntproc): Fix formatting conventions in last change.
This commit is contained in:
parent
de7de561e1
commit
944e45db53
1 changed files with 16 additions and 11 deletions
27
src/w32.c
27
src/w32.c
|
@ -10482,14 +10482,19 @@ init_ntproc (int dumping)
|
|||
{
|
||||
|
||||
#ifdef _UCRT
|
||||
/* For UCRT, the _fdopen will try to find free stream from
|
||||
_IOB_ENTRIES (= 3), thus we can't reopen the standard handles
|
||||
with it. Using SetHandleInformation to make the handle not
|
||||
inheritable to child process is a better way. */
|
||||
SetHandleInformation (GetStdHandle(STD_INPUT_HANDLE), HANDLE_FLAG_INHERIT, 0);
|
||||
SetHandleInformation (GetStdHandle(STD_OUTPUT_HANDLE), HANDLE_FLAG_INHERIT, 0);
|
||||
SetHandleInformation (GetStdHandle(STD_ERROR_HANDLE), HANDLE_FLAG_INHERIT, 0);
|
||||
#else
|
||||
/* The non-UCRT code below relies on MSVCRT-only behavior, whereby
|
||||
_fdopen reuses the first unused FILE slot, whereas UCRT skips the
|
||||
first 3 slots, which correspond to stdin/stdout/stderr. That
|
||||
makes it impossible in the UCRT build to open these 3 streams
|
||||
once they are closed. So we use SetHandleInformation instead,
|
||||
which is available on all versions of Windows that have UCRT. */
|
||||
SetHandleInformation (GetStdHandle(STD_INPUT_HANDLE),
|
||||
HANDLE_FLAG_INHERIT, 0);
|
||||
SetHandleInformation (GetStdHandle(STD_OUTPUT_HANDLE),
|
||||
HANDLE_FLAG_INHERIT, 0);
|
||||
SetHandleInformation (GetStdHandle(STD_ERROR_HANDLE),
|
||||
HANDLE_FLAG_INHERIT, 0);
|
||||
#else /* !_UCRT */
|
||||
HANDLE parent;
|
||||
HANDLE stdin_save = INVALID_HANDLE_VALUE;
|
||||
HANDLE stdout_save = INVALID_HANDLE_VALUE;
|
||||
|
@ -10497,8 +10502,8 @@ init_ntproc (int dumping)
|
|||
|
||||
parent = GetCurrentProcess ();
|
||||
|
||||
/* ignore errors when duplicating and closing; typically the
|
||||
handles will be invalid when running as a gui program. */
|
||||
/* Ignore errors when duplicating and closing; typically the
|
||||
handles will be invalid when running as a gui program. */
|
||||
DuplicateHandle (parent,
|
||||
GetStdHandle (STD_INPUT_HANDLE),
|
||||
parent,
|
||||
|
@ -10544,7 +10549,7 @@ init_ntproc (int dumping)
|
|||
else
|
||||
_open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY);
|
||||
_fdopen (2, "w");
|
||||
#endif
|
||||
#endif /* !_UCRT */
|
||||
}
|
||||
|
||||
/* unfortunately, atexit depends on implementation of malloc */
|
||||
|
|
Loading…
Add table
Reference in a new issue