X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/9385eb3d10ebe5eb398c52040ec3dbfba9b0cdcf..6dccf0e0b5e80b7b6176e8d332e646175431bb3d:/gen/FreeBSD/setprogname.c diff --git a/gen/FreeBSD/setprogname.c b/gen/FreeBSD/setprogname.c index 654bef4..2392a66 100644 --- a/gen/FreeBSD/setprogname.c +++ b/gen/FreeBSD/setprogname.c @@ -3,6 +3,10 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/setprogname.c,v 1.8 2002/03/29 22:43:41 mar #include #include +#include +#include +#include +#define __progname (*_NSGetProgname()) #include "libc_private.h" @@ -10,10 +14,20 @@ void setprogname(const char *progname) { const char *p; - + char buf[2*MAXCOMLEN+1]; + int mib[2]; + p = strrchr(progname, '/'); if (p != NULL) - __progname = p + 1; + __progname = (char *)(p = p + 1); else - __progname = progname; + __progname = (char *)(p = progname); + + strlcpy(&buf[0], (char *)(p), sizeof(buf)); + + mib[0] = CTL_KERN; + mib[1] = KERN_PROCNAME; + + /* ignore errors as this is not a hard error */ + sysctl(mib, 2, NULL, NULL, &buf[0], strlen(buf)); }