叉/exec/bin/sh无效参数

发布于 2025-02-08 05:39:37 字数 448 浏览 1 评论 0原文

该问题在MAC上不稳定复制。代码片段如下:

cmd := exec.Command("/bin/zsh", "-c", `brew info goland`)
cmd.SysProcAttr = &syscall.SysProcAttr{
    Credential: &syscall.Credential{
        Uid:    501,
        Gid:    20,
        Groups: []uint32{2, 3, 4},
    },
}
output, err := cmd.CombinedOutput()
if err != nil {
    println(err)
}

我以root运行该过程,并与另一个用户一起执行command。它在一些Mac计算机上失败并报告“ fork/exec/bin/zsh无效参数”错误消息。 有人知道原因吗?谢谢〜

The issue is not stably reproduced on mac. the code snippet is as below:

cmd := exec.Command("/bin/zsh", "-c", `brew info goland`)
cmd.SysProcAttr = &syscall.SysProcAttr{
    Credential: &syscall.Credential{
        Uid:    501,
        Gid:    20,
        Groups: []uint32{2, 3, 4},
    },
}
output, err := cmd.CombinedOutput()
if err != nil {
    println(err)
}

i run the process as root, and exec command with another user. It failed on some mac computer and report "fork/exec /bin/zsh invalid argument" error message.
anybody know the cause? thanks~

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文