diff --git a/backend/managers/gameLauncher.js b/backend/managers/gameLauncher.js index 4fc7750..9ceada8 100644 --- a/backend/managers/gameLauncher.js +++ b/backend/managers/gameLauncher.js @@ -406,27 +406,20 @@ exec "$REAL_JAVA" "\${ARGS[@]}" spawnOptions.windowsHide = true; } - // Linux: Use wrapper script to ensure LD_PRELOAD is definitely applied - // This works around potential issues with detached spawn not inheriting env properly - let actualClientPath = clientPath; - let actualArgs = args; + let child; + // Linux: Use shell with inline LD_PRELOAD for maximum compatibility if (process.platform === 'linux' && env.LD_PRELOAD) { - const wrapperPath = path.join(path.dirname(clientPath), 'launcher-wrapper.sh'); - const wrapperScript = `#!/bin/bash -# Auto-generated wrapper to ensure LD_PRELOAD is applied -export LD_PRELOAD="${env.LD_PRELOAD}" -exec "$@" -`; - fs.writeFileSync(wrapperPath, wrapperScript, { mode: 0o755 }); - console.log(`Linux: Created wrapper script at ${wrapperPath}`); + const quotedArgs = args.map(a => `"${a.replace(/"/g, '\\"')}"`).join(' '); + const shellCmd = `LD_PRELOAD="${env.LD_PRELOAD}" "${clientPath}" ${quotedArgs}`; + console.log(`Linux: Launching via shell with LD_PRELOAD`); - actualClientPath = wrapperPath; - actualArgs = [clientPath, ...args]; + spawnOptions.shell = '/bin/bash'; + child = spawn(shellCmd, [], spawnOptions); + } else { + child = spawn(clientPath, args, spawnOptions); } - const child = spawn(actualClientPath, actualArgs, spawnOptions); - console.log(`Game process started with PID: ${child.pid}`); let hasExited = false;