diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2023-01-07 05:25:00 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2023-01-07 05:25:00 +0000 |
commit | 8be9c34a92bc776d065a7b50661bf7bd5c764567 (patch) | |
tree | 5227ec96081b287c582622735e28751d6e121c20 /bin/ps | |
parent | d16a8134fa033fab3a6bdf55d0b6953f87a06c3a (diff) |
Add {get,set}thrname(2) for putting thread names in the kernel and
exposed in a new field returned by sysctl(KERN_PROC). Update
pthread_{get,set}_name_np(3) to use the syscalls. Show them, when
set, in ps -H and top -H output.
libc and libpthread minor bumps
ok mpi@, mvs@, deraadt@
Diffstat (limited to 'bin/ps')
-rw-r--r-- | bin/ps/print.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c index 56a78da0cbf..21709700847 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.84 2022/09/20 10:01:51 job Exp $ */ +/* $OpenBSD: print.c,v 1.85 2023/01/07 05:24:59 guenther Exp $ */ /* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */ /*- @@ -95,6 +95,18 @@ printheader(void) (void)putchar('\n'); } +static int +print_comm_name(const struct kinfo_proc *kp, int left, int trail) +{ + left -= mbswprint(kp->p_comm, left, trail); + if (left > 1 && kp->p_name[0] != '\0') { + putchar('/'); + left--; + left -= mbswprint(kp->p_name, left, trail); + } + return left; +} + void command(const struct pinfo *pi, VARENT *ve) { @@ -161,6 +173,7 @@ command(const struct pinfo *pi, VARENT *ve) } } if (argv == NULL || argv[0] == NULL || + kp->p_name[0] != '\0' || strcmp(cmdpart(argv[0]), kp->p_comm)) { if (wantspace) { putchar(' '); @@ -169,7 +182,7 @@ command(const struct pinfo *pi, VARENT *ve) } putchar('('); left--; - left -= mbswprint(kp->p_comm, left, 0); + left -= print_comm_name(kp, left, 0); if (left == 0) return; putchar(')'); @@ -180,7 +193,7 @@ command(const struct pinfo *pi, VARENT *ve) putchar(' '); left--; } - left -= mbswprint(kp->p_comm, left, 0); + left -= print_comm_name(kp, left, 0); } } if (ve->next != NULL) |