git: f942680e8e28 - main - Fix proc_signame() to use sig2str()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 11 Jun 2025 23:16:42 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=f942680e8e282f2347e14c4760583c97ff346adc
commit f942680e8e282f2347e14c4760583c97ff346adc
Author: Ricardo Branco <rbranco@suse.de>
AuthorDate: 2025-05-15 13:52:27 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-06-11 23:16:22 +0000
Fix proc_signame() to use sig2str()
Reviewed by: imp, kib, des, jilles
Pull Request: https://github.com/freebsd/freebsd-src/pull/1696
---
lib/libproc/proc_util.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/libproc/proc_util.c b/lib/libproc/proc_util.c
index bea50fb01098..a062b9a1f461 100644
--- a/lib/libproc/proc_util.c
+++ b/lib/libproc/proc_util.c
@@ -37,6 +37,7 @@
#include <err.h>
#include <errno.h>
#include <signal.h>
+#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -180,8 +181,12 @@ proc_getwstat(struct proc_handle *phdl)
char *
proc_signame(int sig, char *name, size_t namesz)
{
+ char buf[SIG2STR_MAX];
- strlcpy(name, strsignal(sig), namesz);
+ if (sig2str(sig, buf) == 0)
+ (void)snprintf(name, namesz, "SIG%s", buf);
+ else
+ (void)snprintf(name, namesz, "SIG#%d", sig);
return (name);
}