From b4e5beacb900d877b94cf510f6f0afc4dbf1ff56 Mon Sep 17 00:00:00 2001 From: Christophe Bucher Date: Wed, 17 Jun 2015 15:22:21 +0200 Subject: [PATCH] CTRL-C event kills the application All events are disabled! The only way to exit this program is the launched command end. --- compat/win32/git-wrapper.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/compat/win32/git-wrapper.c b/compat/win32/git-wrapper.c index 396a4eec241778..66029cf5cc04ab 100644 --- a/compat/win32/git-wrapper.c +++ b/compat/win32/git-wrapper.c @@ -14,6 +14,15 @@ #include #include +/* +Control Handler Function +All events are disabled! +*/ +BOOL WINAPI CtrlHandler( DWORD fdwCtrlType ) +{ + return TRUE; +} + static WCHAR msystem_bin[64]; static void print_error(LPCWSTR prefix, DWORD error_number) @@ -547,8 +556,11 @@ int main(void) working_directory, /* use parent's */ &si, &pi); if (br) { - if (wait) + if (wait) { + /* The only way to exit this program is the launched command end. */ + SetConsoleCtrlHandler(CtrlHandler, TRUE); WaitForSingleObject(pi.hProcess, INFINITE); + } if (!GetExitCodeProcess(pi.hProcess, (DWORD *)&r)) print_error(L"error reading exit code", GetLastError());