diff options
author | bz <bz@FreeBSD.org> | 2011-07-18 20:57:43 +0000 |
---|---|---|
committer | bz <bz@FreeBSD.org> | 2011-07-18 20:57:43 +0000 |
commit | b0d942176156dee18dd1b4267ad1577b8b4a7f59 (patch) | |
tree | a815f9f926933fa44a9cf0a66415bd5429115718 /usr.bin/top | |
parent | dd1a1f9dcc6243ff5d7d0c235cb8274cac899cc7 (diff) | |
download | FreeBSD-src-b0d942176156dee18dd1b4267ad1577b8b4a7f59.zip FreeBSD-src-b0d942176156dee18dd1b4267ad1577b8b4a7f59.tar.gz |
Constantly print the command name and if set include the thread
name in per-thread mode.
Discussed with: jhb
Obtained from: Ed Maste at Sandvine Incorporated
Sponsored by: Sandvine Incorporated
MFC after: 1 week
Approved by: re (kib)
Diffstat (limited to 'usr.bin/top')
-rw-r--r-- | usr.bin/top/machine.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 94feb9a..5e53d5b 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -834,7 +834,8 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags) if (!(flags & FMT_SHOWARGS)) { if (ps.thread && pp->ki_flag & P_HADTHREADS && pp->ki_tdname[0]) { - snprintf(cmdbuf, cmdlengthdelta, "{%s}", pp->ki_tdname); + snprintf(cmdbuf, cmdlengthdelta, "%s{%s}", pp->ki_comm, + pp->ki_tdname); } else { snprintf(cmdbuf, cmdlengthdelta, "%s", pp->ki_comm); } @@ -846,7 +847,7 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags) if (ps.thread && pp->ki_flag & P_HADTHREADS && pp->ki_tdname[0]) { snprintf(cmdbuf, cmdlengthdelta, - "{%s}", pp->ki_tdname); + "[%s{%s}]", pp->ki_comm, pp->ki_tdname); } else { snprintf(cmdbuf, cmdlengthdelta, "[%s]", pp->ki_comm); @@ -890,12 +891,23 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags) dst--; *dst = '\0'; - if (strcmp(cmd, pp->ki_comm) != 0 ) - snprintf(cmdbuf, cmdlengthdelta, - "%s (%s)",argbuf, pp->ki_comm); - else - strlcpy(cmdbuf, argbuf, cmdlengthdelta); - + if (strcmp(cmd, pp->ki_comm) != 0 ) { + if (ps.thread && pp->ki_flag & P_HADTHREADS && + pp->ki_tdname[0]) + snprintf(cmdbuf, cmdlengthdelta, + "%s (%s){%s}", argbuf, pp->ki_comm, + pp->ki_tdname); + else + snprintf(cmdbuf, cmdlengthdelta, + "%s (%s)", argbuf, pp->ki_comm); + } else { + if (ps.thread && pp->ki_flag & P_HADTHREADS && + pp->ki_tdname[0]) + snprintf(cmdbuf, cmdlengthdelta, + "%s{%s}", argbuf, pp->ki_tdname); + else + strlcpy(cmdbuf, argbuf, cmdlengthdelta); + } free(argbuf); } } |