fix: Use inline shell LD_PRELOAD instead of wrapper script

Simpler approach - pass LD_PRELOAD directly in the shell command
instead of using a wrapper script.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
sanasol
2026-01-27 06:03:52 +01:00
parent 778ed11f87
commit 8ef13c5ee1

View File

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