From a4632f5cc97815a56b1afb9c294e2038cfb35b68 Mon Sep 17 00:00:00 2001
From: Craig Small <csmall@dropbear.xyz>
Date: Tue, 15 Sep 2026 18:22:35 +1000
Subject: [PATCH] kill: Correct exit value for pgrp kills

kill had the logic reversed for program group or negative pid kills.
This meant you got 0 on failure and 1 on success.

Explicitly check for return value of 0 from kill(2) or
sigqueue(3) for success.

References:
 #438

Signed-off-by: Craig Small <csmall@dropbear.xyz>
---
 src/kill.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/kill.c b/src/kill.c
index 93442524..1def3ab7 100644
--- a/src/kill.c
+++ b/src/kill.c
@@ -135,7 +135,7 @@ int main(int argc, char **argv)
                 /* Special case for signal digit negative
                  * PIDs */
                 pid = strtol_or_err(argv[optind], _("failed to parse argument"));
-		if (!execute_kill((pid_t) pid, signo, use_sigqueue, sigval))
+		if (execute_kill((pid_t) pid, signo, use_sigqueue, sigval) != 0)
 		    exitvalue = EXIT_FAILURE;
                 exit(exitvalue);
             }
@@ -152,7 +152,7 @@ int main(int argc, char **argv)
 
     for (i = 0; i < argc; i++) {
         pid = strtol_or_err(argv[i], _("failed to parse argument"));
-        if (!execute_kill((pid_t) pid, signo, use_sigqueue, sigval))
+        if (execute_kill((pid_t) pid, signo, use_sigqueue, sigval) == 0)
             continue;
         error(0, errno, "(%ld)", pid);
         exitvalue = EXIT_FAILURE;
-- 
GitLab

