Eric Pouech : cmd: Better handle ctrl-c events.
Module: wine Branch: master Commit: 91cce00dbaf76106dc1f4315c2ffb4dd3ceaa54a URL: https://gitlab.winehq.org/wine/wine/-/commit/91cce00dbaf76106dc1f4315c2ffb4d... Author: Eric Pouech <epouech(a)codeweavers.com> Date: Wed Sep 6 10:07:51 2023 +0200 cmd: Better handle ctrl-c events. cmd shouldn't terminate itself when user hits ctrl-c. cmd should terminate the currently running CUI child it waits for upon ctrl-c. Signed-off-by: Eric Pouech <epouech(a)codeweavers.com> --- programs/cmd/wcmdmain.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index d00c6e07566..cc81534fff3 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -2411,6 +2411,12 @@ void WCMD_free_commands(CMD_LIST *cmds) { } } +static BOOL WINAPI my_event_handler(DWORD ctrl) +{ + WCMD_output(L"\n"); + return ctrl == CTRL_C_EVENT; +} + /***************************************************************************** * Main entry point. This is a console application so we have a main() not a @@ -2658,6 +2664,10 @@ int __cdecl wmain (int argc, WCHAR *argvW[]) if (opt_s && *cmd=='\"') WCMD_strip_quotes(cmd); } + else + { + SetConsoleCtrlHandler(my_event_handler, TRUE); + } /* Save cwd into appropriate env var (Must be before the /c processing */ GetCurrentDirectoryW(ARRAY_SIZE(string), string);
participants (1)
-
Alexandre Julliard