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@codeweavers.com>
This commit is contained in:
Eric Pouech 2023-09-06 10:07:51 +02:00 committed by Alexandre Julliard
parent b228e3df60
commit 91cce00dba

View file

@ -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);