Git development
 help / color / mirror / Atom feed
* [PATCH] compat/mingw: Allow SIGKILL to kill in mingw_kill.
@ 2026-05-22  6:16 Siddh Raman Pant
  2026-05-22  6:32 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Siddh Raman Pant @ 2026-05-22  6:16 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Kristoffer Haugsbakk, Elijah Newren,
	Patrick Steinhardt

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(-)

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] compat/mingw: Allow SIGKILL to kill in mingw_kill.
  2026-05-22  6:16 [PATCH] compat/mingw: Allow SIGKILL to kill in mingw_kill Siddh Raman Pant
@ 2026-05-22  6:32 ` Junio C Hamano
  2026-05-22  8:03   ` Siddh Raman Pant
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2026-05-22  6:32 UTC (permalink / raw)
  To: Siddh Raman Pant, Johannes Sixt, Johannes Schindelin
  Cc: git, Kristoffer Haugsbakk, Elijah Newren, Patrick Steinhardt

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.
>
> 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.

> 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)) {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] compat/mingw: Allow SIGKILL to kill in mingw_kill.
  2026-05-22  6:32 ` Junio C Hamano
@ 2026-05-22  8:03   ` Siddh Raman Pant
  0 siblings, 0 replies; 3+ messages in thread
From: Siddh Raman Pant @ 2026-05-22  8:03 UTC (permalink / raw)
  To: j6t@kdbg.org, gitster@pobox.com, Johannes.Schindelin@gmx.de
  Cc: git@vger.kernel.org, code@khaugsbakk.name, newren@gmail.com,
	ps@pks.im

[-- Attachment #1: Type: text/plain, Size: 1874 bytes --]

On Fri, May 22 2026 at 12:02:52 +0530, Junio C Hamano wrote:
> 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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-22  8:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-22  6:16 [PATCH] compat/mingw: Allow SIGKILL to kill in mingw_kill Siddh Raman Pant
2026-05-22  6:32 ` Junio C Hamano
2026-05-22  8:03   ` Siddh Raman Pant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox