launcher_main: automatically set LD_LIBRARY_PATH on launch

This commit is contained in:
nillerusr 2022-09-17 18:26:41 +03:00
parent 54f174d262
commit 2dca8fd6c7

View File

@ -216,6 +216,25 @@ static void WaitForDebuggerConnect( int argc, char *argv[], int time )
int main( int argc, char *argv[] )
{
char ld_path[4196];
char *path = "bin/";
char *ld_env;
if( (ld_env = getenv("LD_LIBRARY_PATH")) != NULL )
{
snprintf(ld_path, sizeof(ld_path), "%s:bin/", ld_env);
path = ld_path;
}
setenv("LD_LIBRARY_PATH", path, 1);
extern char** environ;
if( getenv("NO_EXECVE_AGAIN") == NULL )
{
setenv("NO_EXECVE_AGAIN", "1", 1);
execve(argv[0], argv, environ);
}
void *launcher = dlopen( "bin/liblauncher" DLL_EXT_STRING, RTLD_NOW );
if ( !launcher )
fprintf( stderr, "%s\nFailed to load the launcher\n", dlerror() );