跳到主要内容

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

浏览文件

stopped.go

35 行 · 1008 B历史下载
1package managedproxy
2
3import (
4 "context"
5 "errors"
6 "os"
7 "os/exec"
8 "path/filepath"
9 "runtime"
10 "strconv"
11)
12
13// ConfirmStopped performs no cleanup. Linux and Windows remove their private
14// process record only after stopping the identified process. launchd retains
15// its plist even after bootout, so an existing plist needs a service lookup.
16func ConfirmStopped(ctx context.Context, profile string) error {
17 path := filepath.Join(Dir(profile), "managed-process.json")
18 if runtime.GOOS == "darwin" {
19 path = servicePath(profile)
20 }
21 if _, err := os.Lstat(path); os.IsNotExist(err) {
22 return nil
23 } else if err != nil {
24 return err
25 }
26 if runtime.GOOS == "darwin" {
27 name := "gui/" + strconv.Itoa(os.Getuid()) + "/" + label(profile)
28 err := exec.CommandContext(ctx, "/bin/launchctl", "print", name).Run()
29 var exit *exec.ExitError
30 if errors.As(err, &exit) && exit.ExitCode() == 113 {
31 return nil
32 } // service not found
33 }
34 return errors.New("无法确认此配置的代理进程已经退出")
35}