Stumbled upon this while reviewing MR!6869.
It looks like default ctrl-c handlers return a given value. No app known to require this.
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/kernel32/tests/console.c | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 61a6f67fe5e..1e9bc48f94b 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -5331,6 +5331,44 @@ static void test_CtrlHandlerSubsystem(void) winetest_pop_context(); }
+ /* test default handlers return code */ + res = snprintf(buf, ARRAY_SIZE(buf), ""%s" console no_ctrl_handler %p", cuiexec, event_child); + ok((LONG)res >= 0 && res < ARRAY_SIZE(buf), "Truncated string %s (%lu)\n", buf, res); + + ret = CreateProcessA(NULL, buf, NULL, NULL, TRUE, 0, NULL, NULL, &si, &info); + ok(ret, "CreateProcess failed: %lu %s\n", GetLastError(), cuiexec); + + res = WaitForSingleObject(event_child, 5000); + ok(res == WAIT_OBJECT_0, "Child didn't init %lu\n", res); + + pgid = RtlGetCurrentPeb()->ProcessParameters->ProcessGroupId; + ret = GenerateConsoleCtrlEvent(CTRL_C_EVENT, pgid); + if (!ret && broken(GetLastError() == ERROR_INVALID_PARAMETER) /* Win7 */) + { + win_skip("Skip test on Win7\n"); + TerminateProcess(info.hProcess, 0); + } + else + { + ok(ret, "GenerateConsoleCtrlEvent failed: %lu\n", GetLastError()); + + res = WaitForSingleObject(info.hProcess, 2000); + ok(res == WAIT_OBJECT_0, "Expecting child to be terminated\n"); + + if (ret) + { + ret = GetExitCodeProcess(info.hProcess, &exit_code); + ok(ret, "Couldn't get exit code\n"); + + todo_wine + ok(exit_code == STATUS_CONTROL_C_EXIT, "Unexpected exit code %#lx, instead of %#lx\n", + exit_code, STATUS_CONTROL_C_EXIT); + } + } + + CloseHandle(info.hProcess); + CloseHandle(info.hThread); + CloseHandle(event_child);
RtlGetCurrentPeb()->ProcessParameters->ConsoleFlags = saved_console_flags; @@ -5384,6 +5422,24 @@ START_TEST(console) ExitProcess(mch_child_event); }
+ if (argc == 4 && !strcmp(argv[2], "no_ctrl_handler")) + { + HANDLE event; + + SetConsoleCtrlHandler(NULL, FALSE); + sscanf(argv[3], "%p", &event); + ret = SetEvent(event); + ok(ret, "SetEvent failed\n"); + + event = CreateEventA(NULL, FALSE, FALSE, NULL); + ok(event != NULL, "Couldn't create event\n"); + + /* wait for parent to kill us */ + WaitForSingleObject(event, INFINITE); + ok(0, "Shouldn't happen\n"); + ExitProcess(0xff); + } + if (argc == 3 && !strcmp(argv[2], "check_console")) { DWORD exit_code = 0, pcslist;
From: Eric Pouech epouech@codeweavers.com
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/kernel32/tests/console.c | 1 - dlls/kernelbase/console.c | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 1e9bc48f94b..03491b279af 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -5360,7 +5360,6 @@ static void test_CtrlHandlerSubsystem(void) ret = GetExitCodeProcess(info.hProcess, &exit_code); ok(ret, "Couldn't get exit code\n");
- todo_wine ok(exit_code == STATUS_CONTROL_C_EXIT, "Unexpected exit code %#lx, instead of %#lx\n", exit_code, STATUS_CONTROL_C_EXIT); } diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c index 10c8bb25037..97c5462c42f 100644 --- a/dlls/kernelbase/console.c +++ b/dlls/kernelbase/console.c @@ -72,7 +72,10 @@ struct ctrl_handler static BOOL WINAPI default_ctrl_handler( DWORD type ) { FIXME( "Terminating process %lx on event %lx\n", GetCurrentProcessId(), type ); - RtlExitUserProcess( 0 ); + if (type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT) + RtlExitUserProcess( STATUS_CONTROL_C_EXIT ); + else + RtlExitUserProcess( 0 ); return TRUE; }
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 tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=149888
Your paranoid android.
=== debian11b (64 bit WoW report) ===
kernel32: comm.c:1586: Test failed: Unexpected time 1002, expected around 500
user32: win.c:4070: Test failed: Expected active window 0000000004580162, got 0000000000000000. win.c:4071: Test failed: Expected focus window 0000000004580162, got 0000000000000000.