mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-07 02:10:27 +00:00
GetProgramExecutableName handles old loaders
This commit is contained in:
parent
860bf7ec17
commit
3b58dbbe0c
1 changed files with 6 additions and 2 deletions
|
@ -97,14 +97,18 @@ static inline void InitProgramExecutableNameImpl(void) {
|
|||
}
|
||||
cmd[3] = -1; // current process
|
||||
if (sys_sysctl(cmd, ARRAYLEN(cmd), b, &n, 0, 0) != -1) {
|
||||
goto UseBuf;
|
||||
if (strcmp(b, "/usr/bin/ape")) { // XX old loader; warn?
|
||||
goto UseBuf;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (IsLinux()) {
|
||||
if ((got = sys_readlinkat(AT_FDCWD, "/proc/self/exe", b, n)) > 0 ||
|
||||
(got = sys_readlinkat(AT_FDCWD, "/proc/curproc/file", b, n)) > 0) {
|
||||
b[got] = 0;
|
||||
goto UseBuf;
|
||||
if (strcmp(b, "/usr/bin/ape")) {
|
||||
goto UseBuf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue