go system_error ai_generated true

错误:信号:被杀死

error: signal: killed

ID: go/os-exec-command-killed

其他格式: JSON · Markdown 中文 · English
80%修复率
84%置信度
0证据数
2024-03-15首次发现

版本兼容性

版本状态引入弃用备注
1.20 active — — —
1.21 active — — —

根因分析

执行的命令被操作系统信号终止,通常为SIGKILL,由于资源限制或手动干预。

English

The executed command was terminated by an operating system signal, typically SIGKILL, due to resource limits or manual intervention.

generic

解决方案

  1. 85% 成功率 Use exec.Cmd with SysProcAttr to set process group and handle signals
    cmd := exec.Command("command")
    cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
    if err := cmd.Run(); err != nil {
        if exitErr, ok := err.(*exec.ExitError); ok {
            if status, ok := exitErr.Sys().(syscall.WaitStatus); ok {
                if status.Signaled() { /* handle signal */ }
            }
        }
    }

无效尝试

常见但无效的做法:

  1. Restarting the command without investigating 70% 失败

    May be killed again due to same resource issue; check OOM killer or ulimit.