mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-17 02:16:43 +00:00
fix(targets): DRY signal handling, remove redundant guards, harden config manager
- Extract signal forwarding to reusable src/utils/signal-forwarder.ts - Update shell-executor, claude-adapter, droid-adapter to use shared utility - Remove 35 lines of redundant duplicate guards in src/ccs.ts - Harden droid-config-manager with lock constants and race-safe ensureFactoryDir - Update help-command with --target usage examples - Update maintainability metrics baseline
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
import { spawn, spawnSync, ChildProcess } from 'child_process';
|
||||
import { ErrorManager } from './error-manager';
|
||||
import { getWebSearchHookEnv } from './websearch-manager';
|
||||
import { forwardSignals } from './signal-forwarder';
|
||||
|
||||
/**
|
||||
* Strip ANTHROPIC_* env vars from an environment object.
|
||||
@@ -127,24 +128,7 @@ export function execClaude(
|
||||
});
|
||||
}
|
||||
|
||||
const forwardSigInt = () => {
|
||||
if (!child.killed) child.kill('SIGINT');
|
||||
};
|
||||
const forwardSigTerm = () => {
|
||||
if (!child.killed) child.kill('SIGTERM');
|
||||
};
|
||||
const forwardSighup = () => {
|
||||
if (!child.killed) child.kill('SIGHUP');
|
||||
};
|
||||
process.on('SIGINT', forwardSigInt);
|
||||
process.on('SIGTERM', forwardSigTerm);
|
||||
process.on('SIGHUP', forwardSighup);
|
||||
|
||||
const cleanupSignalHandlers = () => {
|
||||
process.removeListener('SIGINT', forwardSigInt);
|
||||
process.removeListener('SIGTERM', forwardSigTerm);
|
||||
process.removeListener('SIGHUP', forwardSighup);
|
||||
};
|
||||
const cleanupSignalHandlers = forwardSignals(child);
|
||||
|
||||
child.on('exit', (code, signal) => {
|
||||
cleanupSignalHandlers();
|
||||
|
||||
Reference in New Issue
Block a user