diff options
author | yar <yar@FreeBSD.org> | 2007-10-27 16:13:31 +0000 |
---|---|---|
committer | yar <yar@FreeBSD.org> | 2007-10-27 16:13:31 +0000 |
commit | 59761712e08a3aaff52ba55fc163766f100b9d0b (patch) | |
tree | 8332f9656564c5e911d2b775aad385b6e96db517 /usr.sbin/crunch/crunchgen/crunched_main.c | |
parent | 0b0826633ebc1ec3f6feb3b32e1c7a373b73fe5a (diff) | |
download | FreeBSD-src-59761712e08a3aaff52ba55fc163766f100b9d0b.zip FreeBSD-src-59761712e08a3aaff52ba55fc163766f100b9d0b.tar.gz |
Set the program name if the crunched program is selected through
argv[1] to mimic crt0 behaviour. Do the job by a direct assignment
to __progname in order to stay compatible with NetBSD, whose
setprogname() is a deliberate no-op.
The reason for this change is that some programs (usually those
imported from NetBSD) use getprogname() to distinguish between their
aliases. (See pkill aka pgrep for example.)
This change can be useful, and applicable, to NetBSD, too.
Diffstat (limited to 'usr.sbin/crunch/crunchgen/crunched_main.c')
-rw-r--r-- | usr.sbin/crunch/crunchgen/crunched_main.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/usr.sbin/crunch/crunchgen/crunched_main.c b/usr.sbin/crunch/crunchgen/crunched_main.c index 2cf9576..7780aa5 100644 --- a/usr.sbin/crunch/crunchgen/crunched_main.c +++ b/usr.sbin/crunch/crunchgen/crunched_main.c @@ -41,6 +41,7 @@ struct stub { int (*f)(); }; +extern char *__progname; extern struct stub entry_points[]; int main(int argc, char **argv, char **envp) @@ -83,12 +84,16 @@ int crunched_here(char *path) int crunched_main(int argc, char **argv, char **envp) { + char *slash; struct stub *ep; int columns, len; if(argc <= 1) crunched_usage(); + slash = strrchr(argv[1], '/'); + __progname = slash? slash+1 : argv[1]; + return main(--argc, ++argv, envp); } |