From cf2e4fefa449d64cda87b9ecf8ed14de0f10fd79 Mon Sep 17 00:00:00 2001 From: "swe-agent[bot]" <0+swe-agent[bot]@users.noreply.github.com> Date: Wed, 10 Dec 2025 16:29:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(codeagent-wrapper):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E9=87=8D=E5=A4=8D=20nil=20=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改进信号转发函数的可读性和可维护性: - 提取 signalNotifyFn 和 signalStopFn 的默认值设置 - 消除嵌套的 nil 检查 - 保持相同的功能行为 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- codeagent-wrapper/executor.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/codeagent-wrapper/executor.go b/codeagent-wrapper/executor.go index 20b23e0..0e70afb 100644 --- a/codeagent-wrapper/executor.go +++ b/codeagent-wrapper/executor.go @@ -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))