Use a better fallback in case `get_exe_filename` fails
This commit is contained in:
parent
1b1c13e3de
commit
66198eb327
|
@ -51,7 +51,7 @@ static void get_exe_filename(char *buf, int sz) {
|
||||||
const int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
|
const int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
|
||||||
sysctl(mib, 4, buf, &len, NULL, 0);
|
sysctl(mib, 4, buf, &len, NULL, 0);
|
||||||
#else
|
#else
|
||||||
strcpy(buf, "./lite");
|
*buf = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,12 @@ init_lua:
|
||||||
|
|
||||||
char exename[2048];
|
char exename[2048];
|
||||||
get_exe_filename(exename, sizeof(exename));
|
get_exe_filename(exename, sizeof(exename));
|
||||||
|
if (*exename) {
|
||||||
lua_pushstring(L, exename);
|
lua_pushstring(L, exename);
|
||||||
|
} else {
|
||||||
|
// get_exe_filename failed
|
||||||
|
lua_pushstring(L, argv[0]);
|
||||||
|
}
|
||||||
lua_setglobal(L, "EXEFILE");
|
lua_setglobal(L, "EXEFILE");
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
Loading…
Reference in New Issue