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:
Tam Nhu Tran
2026-02-17 03:38:27 +07:00
parent f1a61f6eb5
commit 02af8d5737
8 changed files with 61 additions and 95 deletions
+2 -18
View File
@@ -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();