fix(codeagent-wrapper): 重构信号处理逻辑避免重复 nil 检查

改进信号转发函数的可读性和可维护性:
- 提取 signalNotifyFn 和 signalStopFn 的默认值设置
- 消除嵌套的 nil 检查
- 保持相同的功能行为

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
swe-agent[bot]
2025-12-10 16:29:32 +08:00
parent d7bb28a9ce
commit cf2e4fefa4

View File

@@ -641,15 +641,20 @@ func runCodexTaskWithContext(parentCtx context.Context, taskSpec TaskSpec, custo
}
func forwardSignals(ctx context.Context, cmd commandRunner, logErrorFn func(string)) {
sigCh := make(chan os.Signal, 1)
if signalNotifyFn != nil {
signalNotifyFn(sigCh, syscall.SIGINT, syscall.SIGTERM)
notify := signalNotifyFn
stop := signalStopFn
if notify == nil {
notify = signal.Notify
}
if stop == nil {
stop = signal.Stop
}
sigCh := make(chan os.Signal, 1)
notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
go func() {
if signalStopFn != nil {
defer signalStopFn(sigCh)
}
defer stop(sigCh)
select {
case sig := <-sigCh:
logErrorFn(fmt.Sprintf("Received signal: %v", sig))