diff --git a/usr.bin/procstat/procstat_bin.c b/usr.bin/procstat/procstat_bin.c index 04482e5ee1b..d3061c1ac42 100644 --- a/usr.bin/procstat/procstat_bin.c +++ b/usr.bin/procstat/procstat_bin.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -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);