Index: m_netbsd.c =================================================================== RCS file: /src/cvs/cvsroot/netbsd/src/external/bsd/top/dist/machine/m_netbsd.c,v retrieving revision 1.5.8.1 diff -a -u -r1.5.8.1 m_netbsd.c --- m_netbsd.c 1 Apr 2009 00:25:21 -0000 1.5.8.1 +++ m_netbsd.c 18 May 2009 07:01:41 -0000 @@ -106,7 +106,7 @@ /* 0123456 -- field to fill in starts at header+6 */ #define PROC_UNAME_START 6 #define Proc_format \ - "%5d %-8.8s %3d %4d%7s %5s %-8.8s%7s %5.2f%% %5.2f%% %.12s" + "%5d %-8.8s %3d %4d%7s %5s %-8.8s%7s %5.2f%% %5.2f%% %s" static char Thread_header[] = " PID LID X PRI STATE TIME WCPU CPU COMMAND NAME"; @@ -780,11 +780,13 @@ char wmesg[KI_WMESGLEN + 1]; static char fmt[MAX_COLS]; /* static area where result is built */ char *pretty = ""; + char *commandline; /* find and remember the next proc structure */ hp = (struct handle *)handle; pp = *(hp->next_proc++); hp->remaining--; + commandline = pp->p_comm; /* get the process's user struct and set cputime */ if ((pp->p_flag & L_INMEM) == 0) @@ -806,6 +808,29 @@ comm[COMSIZ - 2] = '\0'; (void) strncat(comm, &pretty[1], COMSIZ - 1); comm[COMSIZ - 1] = '\0'; + } else { + static char buf[1024]; + char **argv; + + argv = kvm_getargv2(kd, pp, sizeof(buf)); + + if (argv != NULL) { + char *p, *pe, *arg; + + commandline = p = buf; + pe = buf + sizeof(buf) - 1; + + for (; *argv != NULL; argv++) { + arg = *argv; + while (*arg && p=pe) + break; + *p++ = ' '; + } + *p++ = '\0'; + } } #if 0 @@ -840,7 +865,8 @@ } #endif /* format this entry */ - sprintf(fmt, + snprintf(fmt, + sizeof(fmt) - 1, Proc_format, pp->p_pid, (*userprint)(pp->p_ruid), @@ -852,7 +878,7 @@ format_time(cputime), 100.0 * weighted_cpu(p_, pct, pp), 100.0 * pct, - printable(pp->p_comm)); + printable(commandline)); /* return the result */ return(fmt);