437
const { stdout, code } = await exec(`cat ${stateFile} 2>/dev/null`, { ignoreExitCode: true });
438
if (code === 0 && stdout.trim()) {
440
>
try {
441
>
state = parseRemoteAgentHostState(JSON.parse(stdout.trim()));
442
>
} catch { /* ignore parse errors */ }
443
>
if (state) {
444
logService.info(`${LOG_PREFIX} Killing remote agent host PID ${state.pid} (from ${stateFile})`);
445
await exec(`kill ${state.pid} 2>/dev/null`, { ignoreExitCode: true });
446
}
448
await exec(`rm -f ${stateFile}`, { ignoreExitCode: true });
449
}