Skip to content

Commit

Permalink
basename
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Mar 31, 2024
1 parent 14344b3 commit 716fb98
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions bsd/kinfo_getargv.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@
#include <sys/proc.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 716fb98

Please sign in to comment.