some console fixes (for ctrl-c handling)

Eric Pouech pouech-eric at
Wed Oct 6 14:19:30 CDT 2004

Ferenc Wagner a écrit :
> Eric Pouech <pouech-eric at> writes:
>>	- ctrl-c enabling flag is now inherited
>>	- fixed console-related fields in RTL_USER_PROCESS_PARAMETERS
>>	- various clean-up in kernel32.SetConsoleCtrlHandler
>>	- only send a console event once to a process and not to all the process' threads
>>+    ok(GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0), "Couldn't send ctrl-c event\n");
>>+    todo_wine ok(mch_count == 1, "Event isn't synchronous\n");
>>+    ok(WaitForSingleObject(mch_event, 3000) == WAIT_OBJECT_0, "event sending didn't work\n");
>>+    CloseHandle(mch_event);
>>+    ok(SetConsoleCtrlHandler(NULL, TRUE), "Couldn't turn off ctrl-c handling\n");
>>+    mch_event = CreateEventA(NULL, TRUE, FALSE, NULL);
>>+    mch_count = 0;
>>+    ok(GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0), "Couldn't send ctrl-c event\n");
> Hi Eric,
> these Ctrl-C events kill off winetest under XP.  You
> probably did your tests and found this OK, so I'm not sure
> what to do.  Can you offer a solution?  I commented those
> two lines out, which made it go through...
Yes I tested them on XP, and they were fine. But I did the test with 
make test, not winetest, which may differ in their testing environments, 
console wise I mean.
What could likely happen is:
- winetest and the tested program share the same console
- we set a console event handler in the test program (but not in winetest)
- we send a ctrl-c event to the console, which is propagated to all 
event handlers of each process
- the one in the test program does it's job
- we didn't install one in winetest, so the event is passed to the 
default handler, which default behavior is to kill itself (winetest)

possible solutions are:
- install a controle event handler in winetest, but you wouldn't be able 
to stop it by ctrl-c which is not really what you want
- recreate a different console for this particular test in kernel/tests, 
which sounds the most reasonable way to control the environment of the test


More information about the wine-devel mailing list