Commit 5fbd6044 authored by Shenghou Ma's avatar Shenghou Ma

syscall: workaround Dragonfly BSD kernel exec bug

See also CL 4259056 for FreeBSD.

Test program:
// exec.go
package main
import (
        "log"
        "os"
        "os/exec"
        "runtime"
)
func main() {
        path := runtime.GOROOT() + "/src/pkg/net/http/cgi/testdata"
        cmd := &exec.Cmd{
                Path:   "test.cgi",
                Args:   []string{path + "/test.cgi"},
                Dir:    path
                Stdout: os.Stdout}
        if err := cmd.Start(); err != nil {
                log.Fatal(err)
        }
        if err := cmd.Wait(); err != nil {
                log.Fatal(err)
        }
}

$ go run exec.go
2014/03/01 15:52:41 fork/exec test.cgi: argument list too long

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/69970044
parent 5b456c74
......@@ -158,7 +158,7 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
return 0, err
}
if runtime.GOOS == "freebsd" && len(argv[0]) > len(argv0) {
if (runtime.GOOS == "freebsd" || runtime.GOOS == "dragonfly") && len(argv[0]) > len(argv0) {
argvp[0] = argv0p
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment