* [PATCH] program_invocation_name
@ 2013-04-05 2:51 Rich Felker
0 siblings, 0 replies; only message in thread
From: Rich Felker @ 2013-04-05 2:51 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 88 bytes --]
In case we want to add it, here is a patch for
program_invocation_name. Comments?
Rich
[-- Attachment #2: progname.diff --]
[-- Type: text/plain, Size: 1291 bytes --]
diff --git a/src/env/__libc_start_main.c b/src/env/__libc_start_main.c
index 04a454e..3ccd979 100644
--- a/src/env/__libc_start_main.c
+++ b/src/env/__libc_start_main.c
@@ -8,8 +8,9 @@ void __init_ldso_ctors(void);
#define AUX_CNT 38
extern size_t __hwcap, __sysinfo;
+extern const char *__progname, *__progname_full;
-void __init_libc(char **envp)
+void __init_libc(char **envp, char *pn)
{
size_t i, *auxv, aux[AUX_CNT] = { 0 };
__environ = envp;
@@ -19,6 +20,11 @@ void __init_libc(char **envp)
__hwcap = aux[AT_HWCAP];
__sysinfo = aux[AT_SYSINFO];
+ if (pn) {
+ __progname = __progname_full = pn;
+ for (i=0; pn[i]; i++) if (pn[i]=='/') __progname = pn+i+1;
+ }
+
__init_tls(aux);
__init_security(aux);
}
@@ -30,7 +36,7 @@ int __libc_start_main(
{
char **envp = argv+argc+1;
- __init_libc(envp);
+ __init_libc(envp, argv[0]);
libc.ldso_fini = ldso_fini;
libc.fini = fini;
diff --git a/src/internal/libc.c b/src/internal/libc.c
index d22d274..7e05f85 100644
--- a/src/internal/libc.c
+++ b/src/internal/libc.c
@@ -16,3 +16,7 @@ __asm__(".hidden __libc");
size_t __hwcap;
size_t __sysinfo;
+const char *__progname=0, *__progname_full=0;
+
+weak_alias(__progname, program_invocation_short_name);
+weak_alias(__progname_full, program_invocation_name);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-04-05 2:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-05 2:51 [PATCH] program_invocation_name Rich Felker
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).