diff --git a/lib/libc/gen/setprogname.c b/lib/libc/gen/setprogname.c index 6c56013ef7c4..da791f819a2f 100644 --- a/lib/libc/gen/setprogname.c +++ b/lib/libc/gen/setprogname.c @@ -8,6 +8,8 @@ extern const char *__progname; void setprogname(const char *progname) { + char *p; - __progname = progname; + p = strrchr('/', progname); + __progname = p ? p+1 : progname; }