跳到主要内容

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

浏览文件

start_unix.go

48 行 · 1.3 KB历史下载
1//go:build !windows
2
3// SPDX-FileCopyrightText: Copyright The Lima Authors
4// SPDX-License-Identifier: Apache-2.0
5
6package instance
7
8import (
9 "fmt"
10 "os"
11 "os/exec"
12 "syscall"
13
14 "github.com/mattn/go-isatty"
15 "github.com/sirupsen/logrus"
16
17 "github.com/lima-vm/lima/v2/pkg/osutil"
18)
19
20func execHostAgentForeground(limactl string, haCmd *exec.Cmd) error {
21 haStdoutW, ok := haCmd.Stdout.(*os.File)
22 if !ok {
23 return fmt.Errorf("expected haCmd.Stdout to be *os.File, got %T", haCmd.Stdout)
24 }
25 haStderrW, ok := haCmd.Stderr.(*os.File)
26 if !ok {
27 return fmt.Errorf("expected haCmd.Stderr to be *os.File, got %T", haCmd.Stderr)
28 }
29 logrus.Info("Running the host agent in the foreground")
30 if isatty.IsTerminal(os.Stdin.Fd()) || isatty.IsCygwinTerminal(os.Stdin.Fd()) {
31 // Write message to standard log files to avoid confusing users
32 message := "This log file is not used because `limactl start` was launched in the terminal with the `--foreground` option."
33 if _, err := haStdoutW.WriteString(message); err != nil {
34 return err
35 }
36 if _, err := haStderrW.WriteString(message); err != nil {
37 return err
38 }
39 } else {
40 if err := osutil.Dup2(int(haStdoutW.Fd()), syscall.Stdout); err != nil {
41 return err
42 }
43 if err := osutil.Dup2(int(haStderrW.Fd()), syscall.Stderr); err != nil {
44 return err
45 }
46 }
47 return syscall.Exec(limactl, haCmd.Args, haCmd.Environ())
48}