At msvcrt init, don't reset the std handle if the inherited handle is invalid.
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/msvcrt/tests/file.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index 75d30648230..9357b215cd8 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -1896,6 +1896,9 @@ static void test_invalid_stdin_child( void ) handle = (HANDLE)_get_osfhandle(STDIN_FILENO); ok(handle == (HANDLE)-2, "handle = %p\n", handle); ok(errno == 0xdeadbeef, "errno = %d\n", errno); + handle = GetStdHandle(STD_INPUT_HANDLE); + todo_wine + ok((LONG_PTR)handle > 0, "Expecting passed handle to be untouched\n");
info = &__pioinfo[STDIN_FILENO/MSVCRT_FD_BLOCK_SIZE][STDIN_FILENO%MSVCRT_FD_BLOCK_SIZE]; ok(info->handle == (HANDLE)-2, "info->handle = %p\n", info->handle);
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/msvcrt/file.c | 12 +++++++----- dlls/msvcrt/tests/file.c | 1 - 2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 3c1d9572585..b4e80a4b5d0 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -560,12 +560,14 @@ static void msvcrt_set_fd(ioinfo *fdinfo, HANDLE hand, int flag) ioinfo_set_unicode(fdinfo, FALSE); ioinfo_set_textmode(fdinfo, TEXTMODE_ANSI);
- if (hand == MSVCRT_NO_CONSOLE) hand = 0; - switch (fdinfo-MSVCRT___pioinfo[0]) + if (hand != MSVCRT_NO_CONSOLE) { - case 0: SetStdHandle(STD_INPUT_HANDLE, hand); break; - case 1: SetStdHandle(STD_OUTPUT_HANDLE, hand); break; - case 2: SetStdHandle(STD_ERROR_HANDLE, hand); break; + switch (fdinfo-MSVCRT___pioinfo[0]) + { + case 0: SetStdHandle(STD_INPUT_HANDLE, hand); break; + case 1: SetStdHandle(STD_OUTPUT_HANDLE, hand); break; + case 2: SetStdHandle(STD_ERROR_HANDLE, hand); break; + } } }
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index 9357b215cd8..1ac6cfe3182 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -1897,7 +1897,6 @@ static void test_invalid_stdin_child( void ) ok(handle == (HANDLE)-2, "handle = %p\n", handle); ok(errno == 0xdeadbeef, "errno = %d\n", errno); handle = GetStdHandle(STD_INPUT_HANDLE); - todo_wine ok((LONG_PTR)handle > 0, "Expecting passed handle to be untouched\n");
info = &__pioinfo[STDIN_FILENO/MSVCRT_FD_BLOCK_SIZE][STDIN_FILENO%MSVCRT_FD_BLOCK_SIZE];
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=139886
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/msvcrt/tests/file.c:1897 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/msvcrt/tests/file.c:1897 Task: Patch failed to apply
=== debian11b (build log) ===
error: patch failed: dlls/msvcrt/tests/file.c:1897 Task: Patch failed to apply
The CI is reporting new kernel32 test failures caused by the patch: ``` process.c:3081: Test failed: TEB:hStdInput expected 0, but got 4294967295 process.c:3082: Test failed: TEB:hStdOutput expected 0, but got 4294967295 process.c:3083: Test failed: TEB:hStdError expected 0, but got 4294967295 process.c:3613: Test failed: TEB:hStdInput expected 0, but got 4294967295 process.c:3614: Test failed: TEB:hStdOutput expected 0, but got 4294967295 process.c:3615: Test failed: TEB:hStdError expected 0, but got 4294967295 ```
this MR is correct, but these failures show some incorrect behavior of CreateProcess which I'm working on (hence the creation of this MR).
Will need to figure out a way to integrate all the changes into something coherent...
This merge request was closed by eric pouech.