From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail•com>
To: git@vger•kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx•de>,
Johannes Schindelin <johannes.schindelin@gmx•de>
Subject: [PATCH 2/2] mingw: really handle SIGINT
Date: Thu, 04 Jun 2026 16:24:20 +0000 [thread overview]
Message-ID: <297cc921fb8c12d85f8bf4c1e05edfbab9609191.1780590261.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2130.git.1780590261.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx•de>
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 <johannes.schindelin@gmx•de>
---
compat/mingw.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/compat/mingw.c b/compat/mingw.c
index 973049ffe3..f2b6c51f98 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -3580,7 +3580,14 @@ static void adjust_symlink_flags(void)
symlink_file_flags |= 2;
symlink_directory_flags |= 2;
}
+}
+static BOOL WINAPI handle_ctrl_c(DWORD ctrl_type)
+{
+ if (ctrl_type != CTRL_C_EVENT)
+ return FALSE; /* we did not handle this */
+ mingw_raise(SIGINT);
+ return TRUE; /* we did handle this */
}
#ifdef _MSC_VER
@@ -3617,6 +3624,8 @@ int wmain(int argc, const wchar_t **wargv)
#endif
#endif
+ SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
+
maybe_redirect_std_handles();
adjust_symlink_flags();
--
gitgitgadget
prev parent reply other threads:[~2026-06-04 16:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 16:24 [PATCH 0/2] mingw: terminate child processes in a gentler way Johannes Schindelin via GitGitGadget
2026-06-04 16:24 ` [PATCH 1/2] mingw: kill " Johannes Schindelin via GitGitGadget
2026-06-04 16:24 ` Johannes Schindelin via GitGitGadget [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=297cc921fb8c12d85f8bf4c1e05edfbab9609191.1780590261.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=johannes.schindelin@gmx$(echo .)de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox