跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

osutil_windows.go

81 行 · 1.7 KB历史下载
1// SPDX-FileCopyrightText: Copyright The Lima Authors
2// SPDX-License-Identifier: Apache-2.0
3
4package osutil
5
6import (
7 "context"
8 "errors"
9 "fmt"
10 "io/fs"
11 "os"
12 "syscall"
13
14 "golang.org/x/sys/windows"
15)
16
17// UnixPathMax is the value of UNIX_PATH_MAX.
18const UnixPathMax = 108
19
20// Stat is a selection of syscall.Stat_t.
21type Stat struct {
22 Uid uint32
23 Gid uint32
24}
25
26func SysStat(_ fs.FileInfo) (Stat, bool) {
27 return Stat{Uid: 0, Gid: 0}, false
28}
29
30// SigInt is the value of SIGINT.
31const SigInt = Signal(2)
32
33// SigTerm is the value of SIGTERM.
34const SigTerm = Signal(15)
35
36// SigKill is the value of SIGKILL.
37const SigKill = Signal(9)
38
39type Signal int
40
41func SysKill(pid int, _ Signal) error {
42 return windows.GenerateConsoleCtrlEvent(syscall.CTRL_BREAK_EVENT, uint32(pid))
43}
44
45// ProcessAlive reports whether the process with the given PID is still running.
46func ProcessAlive(pid int) bool {
47 h, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid))
48 if err != nil {
49 return false
50 }
51 var exitCode uint32
52 err = windows.GetExitCodeProcess(h, &exitCode)
53 _ = windows.CloseHandle(h)
54 if err != nil {
55 return false
56 }
57 return exitCode == 259 // STILL_ACTIVE
58}
59
60func Dup2(_ int, _ syscall.Handle) error {
61 return errors.New("unimplemented")
62}
63
64func SignalName(sig os.Signal) string {
65 switch sig {
66 case syscall.SIGINT:
67 return "SIGINT"
68 case syscall.SIGTERM:
69 return "SIGTERM"
70 default:
71 return fmt.Sprintf("Signal(%d)", sig)
72 }
73}
74
75func Sysctl(_ context.Context, _ string) (string, error) {
76 return "", errors.New("sysctl: unimplemented on Windows")
77}
78
79func IsEACCES(err error) bool {
80 return errors.Is(err, syscall.ERROR_ACCESS_DENIED) || errors.Is(err, syscall.WSAEACCES)
81}