The branch main has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=bff05e8a8c3c64bfe6152870cb758d00991ec66b

commit bff05e8a8c3c64bfe6152870cb758d00991ec66b
Author:     Konstantin Belousov <k...@freebsd.org>
AuthorDate: 2025-06-07 11:29:15 +0000
Commit:     Konstantin Belousov <k...@freebsd.org>
CommitDate: 2025-06-09 23:51:13 +0000

    timeout(1): print errno when signalling syscalls failed
    
    Tested by:      pho
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D50752
---
 bin/timeout/timeout.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/bin/timeout/timeout.c b/bin/timeout/timeout.c
index 424e72dac9ad..05904522c5b5 100644
--- a/bin/timeout/timeout.c
+++ b/bin/timeout/timeout.c
@@ -195,7 +195,7 @@ send_sig(pid_t pid, int signo, bool foreground)
        if (foreground) {
                if (kill(pid, signo) == -1) {
                        if (errno != ESRCH)
-                               warnx("kill(%d, %s)", (int)pid,
+                               warn("kill(%d, %s)", (int)pid,
                                    sys_signame[signo]);
                }
        } else {
@@ -204,11 +204,13 @@ send_sig(pid_t pid, int signo, bool foreground)
                error = procctl(P_PID, getpid(), PROC_REAP_KILL, &rk);
                if (error == 0 || (error == -1 && errno == ESRCH))
                        ;
-               else if (error == -1)
-                       warnx("procctl(PROC_REAP_KILL)");
-               else if (rk.rk_fpid > 0)
-                       warnx("failed to signal some processes: first pid=%d",
-                             (int)rk.rk_fpid);
+               else if (error == -1) {
+                       warn("procctl(PROC_REAP_KILL)");
+                       if (rk.rk_fpid > 0)
+                               warnx(
+                           "failed to signal some processes: first pid=%d",
+                                   (int)rk.rk_fpid);
+               }
                logv("signaled %u processes", rk.rk_killed);
        }
 

Reply via email to