summaryrefslogtreecommitdiffstats
path: root/usr.bin/procstat/procstat.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/procstat/procstat.c')
-rw-r--r--usr.bin/procstat/procstat.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/usr.bin/procstat/procstat.c b/usr.bin/procstat/procstat.c
index 48a2135..a6774e5 100644
--- a/usr.bin/procstat/procstat.c
+++ b/usr.bin/procstat/procstat.c
@@ -34,6 +34,7 @@
#include <libprocstat.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <sysexits.h>
#include <unistd.h>
@@ -115,6 +116,21 @@ kinfo_proc_sort(struct kinfo_proc *kipp, int count)
qsort(kipp, count, sizeof(*kipp), kinfo_proc_compare);
}
+const char *
+kinfo_proc_thread_name(const struct kinfo_proc *kipp)
+{
+ static char name[MAXCOMLEN+1];
+
+ strlcpy(name, kipp->ki_tdname, sizeof(name));
+ strlcat(name, kipp->ki_moretdname, sizeof(name));
+ if (name[0] == '\0' || strcmp(kipp->ki_comm, name) == 0) {
+ name[0] = '-';
+ name[1] = '\0';
+ }
+
+ return (name);
+}
+
int
main(int argc, char *argv[])
{
OpenPOWER on IntegriCloud