Skip to content

Commit 7523016

Browse files
committed
mingw: really handle SIGINT
Previously, we did not install any handler for Ctrl+C, but now we really want to because the MSYS2 runtime learned the trick to call the ConsoleCtrlHandler when Ctrl+C was pressed. With this, hitting Ctrl+C while `git log` is running will only terminate the Git process, but not the pager. This finally matches the behavior on Linux and on macOS. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 0dee222 commit 7523016

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compat/mingw.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3579,7 +3579,14 @@ static void adjust_symlink_flags(void)
35793579
symlink_file_flags |= 2;
35803580
symlink_directory_flags |= 2;
35813581
}
3582+
}
35823583

3584+
static BOOL WINAPI handle_ctrl_c(DWORD ctrl_type)
3585+
{
3586+
if (ctrl_type != CTRL_C_EVENT)
3587+
return FALSE; /* we did not handle this */
3588+
mingw_raise(SIGINT);
3589+
return TRUE; /* we did handle this */
35833590
}
35843591

35853592
#ifdef _MSC_VER
@@ -3615,6 +3622,8 @@ int wmain(int argc, const wchar_t **wargv)
36153622
#endif
36163623
#endif
36173624

3625+
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
3626+
36183627
maybe_redirect_std_handles();
36193628
adjust_symlink_flags();
36203629
fsync_object_files = 1;

0 commit comments

Comments
 (0)