mirror of
https://git.sanhost.net/sanasol/hytale-f2p
synced 2026-02-26 16:21:49 -03:00
fix: Use wrapper script to ensure LD_PRELOAD is applied on Linux
Node.js spawn with detached:true may not properly pass environment variables on some systems. Using a bash wrapper script guarantees LD_PRELOAD is set before the game process starts. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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 {
|
try {
|
||||||
let spawnOptions = {
|
let spawnOptions = {
|
||||||
stdio: ['ignore', 'pipe', 'pipe'],
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
@@ -401,7 +406,26 @@ exec "$REAL_JAVA" "\${ARGS[@]}"
|
|||||||
spawnOptions.windowsHide = true;
|
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}`);
|
console.log(`Game process started with PID: ${child.pid}`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user