go system_error ai_generated true

error: signal: killed

ID: go/os-exec-command-killed

Also available as: JSON · Markdown · 中文
80%Fix Rate
84%Confidence
0Evidence
2024-03-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.20 active
1.21 active

Root Cause

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

generic

中文

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

Workarounds

  1. 85% success 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 */ }
            }
        }
    }

Dead Ends

Common approaches that don't work:

  1. Restarting the command without investigating 70% fail

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