diff --git a/backend/managers/gameLauncher.js b/backend/managers/gameLauncher.js index ce9a7d1..4fc7750 100644 --- a/backend/managers/gameLauncher.js +++ b/backend/managers/gameLauncher.js @@ -389,6 +389,11 @@ exec "$REAL_JAVA" "\${ARGS[@]}" } } + // Debug: log LD_PRELOAD before spawn + if (process.platform === 'linux') { + console.log(`Linux: LD_PRELOAD = ${env.LD_PRELOAD || '(not set)'}`); + } + try { let spawnOptions = { stdio: ['ignore', 'pipe', 'pipe'], @@ -401,7 +406,26 @@ exec "$REAL_JAVA" "\${ARGS[@]}" spawnOptions.windowsHide = true; } - const child = spawn(clientPath, args, spawnOptions); + // 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; + + 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}`); + + actualClientPath = wrapperPath; + actualArgs = [clientPath, ...args]; + } + + const child = spawn(actualClientPath, actualArgs, spawnOptions); console.log(`Game process started with PID: ${child.pid}`);