diff --git a/bsd/kinfo_getargv.c b/bsd/kinfo_getargv.c index 6ace737..5afe648 100644 --- a/bsd/kinfo_getargv.c +++ b/bsd/kinfo_getargv.c @@ -7,12 +7,21 @@ #include #endif +#include #include #include #include "extern.h" static char *kinfo_getpathname(pid_t); +static char *xbasename(const char *s); + +static char * +xbasename(const char *s) { + char *t = strrchr(s, '/'); + printf("xxx\n"); + return ++t; +} static char * kinfo_getpathname(pid_t pid) @@ -92,8 +101,11 @@ kinfo_getargv(pid_t pid) if (buf[0] != '/') { argv[0] = kinfo_getpathname(pid); if (argv[0] != NULL) { - off += strlen(buf) + 1; - i++; + if (!strcmp(xbasename(buf), xbasename(argv[0]))) { + off += strlen(buf) + 1; + i++; + } else + free(argv[0]); } } #endif