aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2026-06-07 07:28:29 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2026-06-08 20:14:20 +0000
commit9f378397ee89044a4faec522916b50f0a164d62e (patch)
tree2ca5a8c90198d2d3f64dd3fa1b29996de2f9ef40
parent888d9236e2249cb1bda686aca8729fdcc69a10ac (diff)
procstat binary: do not skip pid if either path or osrel sysctls failed
PR: 295893 Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D57493
-rw-r--r--usr.bin/procstat/procstat_bin.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/procstat/procstat_bin.c b/usr.bin/procstat/procstat_bin.c
index 04482e5ee1ba..d3061c1ac420 100644
--- a/usr.bin/procstat/procstat_bin.c
+++ b/usr.bin/procstat/procstat_bin.c
@@ -35,6 +35,7 @@
#include <errno.h>
#include <libprocstat.h>
#include <limits.h>
+#include <signal.h>
#include <stdio.h>
#include <string.h>
@@ -50,12 +51,13 @@ procstat_bin(struct procstat *prstat, struct kinfo_proc *kipp)
xo_emit("{T:/%5s %-16s %8s %s}\n", "PID", "COMM", "OSREL",
"PATH");
- if (procstat_getpathname(prstat, kipp, pathname, sizeof(pathname)) != 0)
+ if (kill(kipp->ki_pid, 0) == -1)
return;
- if (strlen(pathname) == 0)
+ if (procstat_getpathname(prstat, kipp, pathname, sizeof(pathname))
+ != 0 || strlen(pathname) == 0)
strcpy(pathname, "-");
if (procstat_getosrel(prstat, kipp, &osrel) != 0)
- return;
+ osrel = -1;
xo_emit("{k:process_id/%5d/%d} ", kipp->ki_pid);
xo_emit("{:command/%-16s/%s} ", kipp->ki_comm);