Go fork / exec权限被拒绝错误 [英] Go fork/exec permission denied error
问题描述
我最近使用CentOS 6.3将Go安装到我们的服务器上。安装似乎没有问题。然而,我做了一个测试hello world脚本,当我运行时,我得到了下面的输出。
$ p $ fork $ / $ /go-build967564990/command-line-arguments/_obj/a.out:权限被拒绝
现在正在运行去env或其他go命令似乎工作。起初,我认为这是一个权限问题,然而,作为root用户运行我得到同样的事情。一个
只是猜测:你的nix可能因安全原因在/ tmp中执行程序而被禁用。它可能可以在CentOS中配置,但我不知道。
另一种解决方案:看来你正在尝试 go run code>来执行一个Go程序(这与C脚本一样是一个脚本)。尝试(假设
$ GOPATH =〜
,简单的可能性),而不是正常的构建,而不是
me:〜/ src / foo $ go run main.go
试试
me:〜/ src / foo $ go build#main.go在这里不需要
me:〜 / src / foo $ ./foo
这种方法仍然使用/ tmp-whatever来创建二进制文件,IIRC,但它不会尝试从那里执行。
PS:不要以root身份运行这些命令。没有必要使用正确的设置。
I recently installed Go onto our server with CentOS 6.3. The install appears to have gone fine. However I made a test "hello world" script, and when I run I get the following output.
fork/exec /tmp/go-build967564990/command-line-arguments/_obj/a.out: permission denied
Now running go env or other go commands seem to work. At first I figured it was a permission issue, however running as root user I get the same thing. An
Just guessing: Your nix perhaps disables for security reasons executing programs in /tmp. It might be configurable in CentOS, but I don't know that.
The alternative solution: It seems you're trying go run
to execute a Go program (which is as script as C is a script). Try (assuming $GOPATH=~
, the easy possibility) instead a normal build, i.e. instead of
me:~/src/foo$ go run main.go
try
me:~/src/foo$ go build # main.go should not be necessary here
me:~/src/foo$ ./foo
This approach will still use /tmp-whatever to create the binary, IIRC, but it will not attempt to execute it from there.
PS: Do not run these command as root. No need for that with correct setup.
这篇关于Go fork / exec权限被拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!