patchcompat/mingw: Allow SIGKILL to kill in mingw_kill.
5 messages between May 22, 2026 and May 28, 2026, from Siddh Raman Pant, Junio C Hamano, Johannes Schindelin.
Plain Markdown or JSON for tools and agents. Diffs are folded; open one to read it.
Siddh Raman PantMay 22, 2026, 06:16 UTC on loremingw_kill() only allows SIGTERM for killing a process.
Let's also allow the natural SIGKILL for the same so that callers don't have to do ifdef soup for special Windows handling.
Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
---
compat/mingw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to compat/mingw.c +1 −1
diff --git a/compat/mingw.c b/compat/mingw.c
index aa7525f419cb..00a994aa9f47 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -2250,7 +2250,7 @@ int mingw_execvp(const char *cmd, char *const *argv)
int mingw_kill(pid_t pid, int sig)
{
- if (pid > 0 && sig == SIGTERM) {
+ if (pid > 0 && (sig == SIGTERM || sig == SIGKILL)) {
HANDLE h = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
if (TerminateProcess(h, -1)) {
--
2.53.0
Re: [PATCH] compat/mingw: Allow SIGKILL to kill in mingw_kill.
Siddh Raman Pant <siddh.raman.pant@oracle.com> writes:
Show 9 quoted lines
> mingw_kill() only allows SIGTERM for killing a process.
>
> Let's also allow the natural SIGKILL for the same so that callers don't
> have to do ifdef soup for special Windows handling.
>
> Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
> ---
> compat/mingw.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
I do not do windows, so I'd like to ask those much more clueful than I am to see if they see any downsides.
The current code only handles TERM (to terminate) or 0 (to probe) and everything else results in EINVAL, so the updated behaviour is to pretend as if TERM is sent and do whatever PROCESS_TERMINATE does, instead of doing nothing and erroring with EINVAL. Which does sound like an improvement over the status quo.
What I am wondering is if there are different kind of "kill" in the Windows land, just like there are distinction between TERM and KILL. For example, the program ought to be able to block TERM but not KILL. There are other termination-inducing signals like SIGQUIT but until we start using them in our code, this emulation layer does not have to know about them, I think.
Thanks.
Show 13 quoted lines
> diff --git a/compat/mingw.c b/compat/mingw.c
> index aa7525f419cb..00a994aa9f47 100644
> --- a/compat/mingw.c
> +++ b/compat/mingw.c
> @@ -2250,7 +2250,7 @@ int mingw_execvp(const char *cmd, char *const *argv)
>
> int mingw_kill(pid_t pid, int sig)
> {
> - if (pid > 0 && sig == SIGTERM) {
> + if (pid > 0 && (sig == SIGTERM || sig == SIGKILL)) {
> HANDLE h = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
>
> if (TerminateProcess(h, -1)) {Re: [PATCH] compat/mingw: Allow SIGKILL to kill in mingw_kill.
On Fri, May 22 2026 at 12:02:52 +0530, Junio C Hamano wrote:
Show 15 quoted lines
> I do not do windows, so I'd like to ask those much more clueful than
> I am to see if they see any downsides.
>
> The current code only handles TERM (to terminate) or 0 (to probe)
> and everything else results in EINVAL, so the updated behaviour is
> to pretend as if TERM is sent and do whatever PROCESS_TERMINATE
> does, instead of doing nothing and erroring with EINVAL. Which does
> sound like an improvement over the status quo.
>
> What I am wondering is if there are different kind of "kill" in the
> Windows land, just like there are distinction between TERM and KILL.
> For example, the program ought to be able to block TERM but not
> KILL. There are other termination-inducing signals like SIGQUIT but
> until we start using them in our code, this emulation layer does not
> have to know about them, I think.
From what I can see from the docs, there is no SIGTERM on Windows either. So I did this change since the SIGTERM handling just looks like a compatibility change in our code.
The docs at [1] says:
The SIGILL and SIGTERM signals aren't generated under Windows.
They're included for ANSI compatibility. Therefore, you can set
signal handlers for these signals by using signal, and you can
also explicitly generate these signals by calling raise.
Our helper uses TerminateProcess(). The docs at [2] says:
The TerminateProcess function is used to unconditionally cause
a process to exit.
[...]
A process cannot prevent itself from being terminated.
which is like SIGKILL.
So currently SIGTERM on Windows is behaving like a SIGKILL.
Thanks, Siddh
[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/signal [2] https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminateprocess
Re: [PATCH] compat/mingw: Allow SIGKILL to kill in mingw_kill.
Hi Junio & Siddh,
On Fri, 22 May 2026, Junio C Hamano wrote:
Show 21 quoted lines
> Siddh Raman Pant <siddh.raman.pant@oracle.com> writes:
>
> > mingw_kill() only allows SIGTERM for killing a process.
> >
> > Let's also allow the natural SIGKILL for the same so that callers don't
> > have to do ifdef soup for special Windows handling.
>
> [...]
>
> The current code only handles TERM (to terminate) or 0 (to probe)
> and everything else results in EINVAL, so the updated behaviour is
> to pretend as if TERM is sent and do whatever PROCESS_TERMINATE
> does, instead of doing nothing and erroring with EINVAL. Which does
> sound like an improvement over the status quo.
>
> What I am wondering is if there are different kind of "kill" in the
> Windows land, just like there are distinction between TERM and KILL.
> For example, the program ought to be able to block TERM but not
> KILL. There are other termination-inducing signals like SIGQUIT but
> until we start using them in our code, this emulation layer does not
> have to know about them, I think.
The version that that Git for Windows carries is actually really different. For one, it gives processes a chance to run their `atexit()` handlers when being terminated via `SIGTERM`.
I'm afraid that the patch under discussion would severely conflict with Git for Windows' code. Git for Windows' code, that is, that should have been upstreamed a long time ago, but wasn't, out of time constraints.
I'll try to polish the patches and upstream them.
Ciao, Johannes
Re: [PATCH] compat/mingw: Allow SIGKILL to kill in mingw_kill.
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 9 quoted lines
> The version that that Git for Windows carries is actually really
> different. For one, it gives processes a chance to run their `atexit()`
> handlers when being terminated via `SIGTERM`.
>
> I'm afraid that the patch under discussion would severely conflict with
> Git for Windows' code. Git for Windows' code, that is, that should have
> been upstreamed a long time ago, but wasn't, out of time constraints.
>
> I'll try to polish the patches and upstream them.