mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-17 06:17:09 +00:00
fix(cursor): kill orphaned daemon on timeout and fix exit codes
MEDIUM fixes: - Kill orphaned process when health check times out after 30s - Prevents zombie processes from consuming resources LOW fixes: - Return exit code 1 for unknown cursor subcommands (was 0) - Simplify exit handler dead code branch (else if code !== null → else)
This commit is contained in:
@@ -48,7 +48,8 @@ export async function handleCursorCommand(args: string[]): Promise<number> {
|
||||
default:
|
||||
console.error(fail(`Unknown subcommand: ${subcommand}`));
|
||||
console.error('');
|
||||
return handleHelp();
|
||||
handleHelp();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -205,6 +205,14 @@ export async function startDaemon(
|
||||
if (await isDaemonRunning(config.port)) {
|
||||
safeResolve({ success: true, pid: proc.pid });
|
||||
} else if (attempts >= maxAttempts) {
|
||||
// Kill orphaned process
|
||||
if (proc.pid) {
|
||||
try {
|
||||
process.kill(proc.pid, 'SIGTERM');
|
||||
} catch {
|
||||
/* already dead */
|
||||
}
|
||||
}
|
||||
safeResolve({
|
||||
success: false,
|
||||
error: 'Daemon did not start within 30 seconds',
|
||||
@@ -230,7 +238,7 @@ export async function startDaemon(
|
||||
success: false,
|
||||
error: 'Daemon process exited unexpectedly with code 0',
|
||||
});
|
||||
} else if (code !== null) {
|
||||
} else {
|
||||
safeResolve({
|
||||
success: false,
|
||||
error: `Daemon process exited with code ${code}`,
|
||||
|
||||
Reference in New Issue
Block a user