mirror of
https://git.sanhost.net/sanasol/hytale-f2p.git
synced 2026-02-26 06:41:47 -03:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user