

























@@ -7,13 +7,44 @@ import (
77"errors"
88"os"
99"os/exec"
10+"path/filepath"
1011"strconv"
12+"strings"
1113)
121415+const defaultWindowsSystemRoot = `C:\Windows`
16+17+func resolveWindowsTaskkillPath() string {
18+systemRoot := normalizeWindowsSystemRoot(os.Getenv("SystemRoot"))
19+if systemRoot == "" {
20+systemRoot = normalizeWindowsSystemRoot(os.Getenv("WINDIR"))
21+ }
22+if systemRoot == "" {
23+systemRoot = defaultWindowsSystemRoot
24+ }
25+return filepath.Join(systemRoot, "System32", "taskkill.exe")
26+}
27+28+func normalizeWindowsSystemRoot(raw string) string {
29+trimmed := strings.TrimSpace(raw)
30+if trimmed == "" ||
31+strings.ContainsAny(trimmed, "\x00\r\n;") ||
32+strings.HasPrefix(trimmed, `\\`) ||
33+!filepath.IsAbs(trimmed) {
34+return ""
35+ }
36+cleaned := filepath.Clean(trimmed)
37+volume := filepath.VolumeName(cleaned)
38+if volume == "" || len(cleaned) <= len(volume)+1 {
39+return ""
40+ }
41+return strings.TrimRight(cleaned, `\/`)
42+}
43+1344var runWindowsTaskkill = func(pid int) error {
1445ctx, cancel := context.WithTimeout(context.Background(), docsI18nCommandWaitDelay())
1546defer cancel()
16-return exec.CommandContext(ctx, "taskkill.exe", "/T", "/F", "/PID", strconv.Itoa(pid)).Run()
47+return exec.CommandContext(ctx, resolveWindowsTaskkillPath(), "/T", "/F", "/PID", strconv.Itoa(pid)).Run()
1748}
18491950func configureCodexPromptCommand(command *exec.Cmd) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。