Date: Tue, 14 Oct 2008 23:51:30 +0000 (UTC) From: Edwin Groothuis <edwin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r183899 - user/edwin/top/top-3.8b1/usr.bin/top Message-ID: <200810142351.m9ENpUJ4019023@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: edwin Date: Tue Oct 14 23:51:30 2008 New Revision: 183899 URL: http://svn.freebsd.org/changeset/base/183899 Log: Display the original command between ()'s just like the old top did when the command and the first argument of the command-line-arguments don't match. According to include/sys/user.h, PS_INMEM is obsoleted in favour of P_INMEM, not the other way around. Modified: user/edwin/top/top-3.8b1/usr.bin/top/machine.c Modified: user/edwin/top/top-3.8b1/usr.bin/top/machine.c ============================================================================== --- user/edwin/top/top-3.8b1/usr.bin/top/machine.c Tue Oct 14 22:48:38 2008 (r183898) +++ user/edwin/top/top-3.8b1/usr.bin/top/machine.c Tue Oct 14 23:51:30 2008 (r183899) @@ -734,9 +734,10 @@ fmt_command(char *buf, int sz, struct ki char *bufp; char **args; char *ps; + char *rawcmd; int argc; -#if OSMAJOR <= 4 +#if OSMAJOR > 4 inmem = (PP(pp, flag) & P_INMEM); #else inmem = (PP(pp, sflag) & PS_INMEM); @@ -747,7 +748,9 @@ fmt_command(char *buf, int sz, struct ki /* get the pargs structure */ if ((args = kvm_getargv(kd, pp, sz)) != NULL) { - /* successfull retrieval: now convert nulls and cr/lf in to spaces */ + /* + * successfull retrieval: now convert nulls and cr/lf in to spaces + */ bufp = cmd; cmd[0] = '\0'; argc = 0; @@ -765,6 +768,17 @@ fmt_command(char *buf, int sz, struct ki *ps = ' '; } + if ((rawcmd = strrchr(args[0], '/')) != NULL) + rawcmd++; + else + rawcmd = args[0]; + + if (strcmp(rawcmd, pp->ki_comm) != 0) { + strcat(cmd, " ("); + strcat(cmd, pp->ki_comm); + strcat(cmd, ")"); + } + /* format cmd as our answer */ return snprintf(buf, sz, "%s", cmd); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810142351.m9ENpUJ4019023>