Changeset View
Changeset View
Standalone View
Standalone View
head/usr.bin/top/machine.c
Show First 20 Lines • Show All 997 Lines • ▼ Show 20 Lines | if (pp->ki_flag & P_SYSTEM || | ||||
cmd = basename(*args); | cmd = basename(*args); | ||||
for (; (src = *args++) != NULL; ) { | for (; (src = *args++) != NULL; ) { | ||||
if (*src == '\0') | if (*src == '\0') | ||||
continue; | continue; | ||||
len = (argbuflen - (dst - argbuf) - 1) / 4; | len = (argbuflen - (dst - argbuf) - 1) / 4; | ||||
strvisx(dst, src, | strvisx(dst, src, | ||||
MIN(strlen(src), len), | MIN(strlen(src), len), | ||||
VIS_NL | VIS_CSTYLE); | VIS_NL | VIS_CSTYLE | VIS_OCTAL | VIS_SAFE); | ||||
while (*dst != '\0') | while (*dst != '\0') | ||||
dst++; | dst++; | ||||
if ((argbuflen - (dst - argbuf) - 1) / 4 > 0) | if ((argbuflen - (dst - argbuf) - 1) / 4 > 0) | ||||
*dst++ = ' '; /* add delimiting space */ | *dst++ = ' '; /* add delimiting space */ | ||||
} | } | ||||
if (dst != argbuf && dst[-1] == ' ') | if (dst != argbuf && dst[-1] == ' ') | ||||
dst--; | dst--; | ||||
*dst = '\0'; | *dst = '\0'; | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | if (smpmode) { | ||||
} else { | } else { | ||||
cpu = pp->ki_lastcpu; | cpu = pp->ki_lastcpu; | ||||
} | } | ||||
sbuf_printf(procbuf, "%3d ", cpu); | sbuf_printf(procbuf, "%3d ", cpu); | ||||
} | } | ||||
sbuf_printf(procbuf, "%6s ", format_time(cputime)); | sbuf_printf(procbuf, "%6s ", format_time(cputime)); | ||||
sbuf_printf(procbuf, "%6.2f%% ", ps.wcpu ? 100.0 * weighted_cpu(PCTCPU(pp), pp) : 100.0 * PCTCPU(pp)); | sbuf_printf(procbuf, "%6.2f%% ", ps.wcpu ? 100.0 * weighted_cpu(PCTCPU(pp), pp) : 100.0 * PCTCPU(pp)); | ||||
} | } | ||||
sbuf_printf(procbuf, "%s", printable(cmdbuf)); | sbuf_printf(procbuf, "%s", cmdbuf); | ||||
free(cmdbuf); | free(cmdbuf); | ||||
return (sbuf_data(procbuf)); | return (sbuf_data(procbuf)); | ||||
} | } | ||||
static void | static void | ||||
getsysctl(const char *name, void *ptr, size_t len) | getsysctl(const char *name, void *ptr, size_t len) | ||||
{ | { | ||||
size_t nlen = len; | size_t nlen = len; | ||||
▲ Show 20 Lines • Show All 448 Lines • Show Last 20 Lines |