Files
gin-vue-admin/server/mcp/process_utils_windows.go
T
PiexlMax(奇淼 375b21c222 发布2.9.1版本 (#2189)
* feat: mcp能力调整为 streamhttp的独立服务 不再依赖gva本体

* feat: 增加MCP启动能力,增加AI工作流需求整理能力。

* feat: 增加需求梳理能力

* feat: 清理无用日志

* feat: 移除无用的Dify Chatflow文本和代码生成器按钮
2026-03-27 12:14:13 +08:00

59 lines
947 B
Go

//go:build windows
package mcpTool
import (
"errors"
"os"
"os/exec"
"syscall"
"golang.org/x/sys/windows"
)
const windowsStillActive = 259
func prepareDetachedProcess(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{
HideWindow: true,
CreationFlags: 0x00000008 | 0x00000200 | 0x08000000,
}
}
func processExists(pid int) bool {
if pid <= 0 {
return false
}
handle, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid))
if err != nil {
return false
}
defer windows.CloseHandle(handle)
var code uint32
if err := windows.GetExitCodeProcess(handle, &code); err != nil {
return false
}
return code == windowsStillActive
}
func terminateProcess(pid int) error {
if pid <= 0 {
return nil
}
process, err := os.FindProcess(pid)
if err != nil {
return err
}
err = process.Kill()
if err == nil || errors.Is(err, os.ErrProcessDone) {
return nil
}
return err
}