From: David du Colombier <0intro@gmail.com> Date: Mon, 13 Jan 2014 22:03:22 +0000 (+0100) Subject: os/exec: disable fd check in TestHelperProcess on Plan 9 X-Git-Tag: go1.3beta1~991 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1f0ca748c24e84fa6849e1d9669232dd99cd61ad;p=gostls13.git os/exec: disable fd check in TestHelperProcess on Plan 9 On Plan 9, we can observe the following open file descriptors: 0 r c 0 (000000000000000a 0 00) 0 0 /dev/null 1 rw | 0 (0000000001df6742 0 00) 65536 54 #|/data1 2 rw | 0 (0000000001df6782 0 00) 65536 0 #|/data1 3 rw M 1956 (0000000000d66dd2 0 00) 8192 12 /tmp/333163398 4 r c 0 (0000000000000001 0 00) 0 528 /dev/bintime 5 r M 1956 (0000000000d66dd1 854 00) 8192 0 /tmp/go-build843954301/os/exec/_test/exec.test 6 r M 1956 (0000000000d66dd1 854 00) 8192 0 /tmp/go-build843954301/os/exec/_test/exec.test 7 r M 1956 (0000000000d66dd1 854 00) 8192 0 /tmp/go-build843954301/os/exec/_test/exec.test 8 r M 1956 (0000000000d66dd1 854 00) 8192 0 /tmp/go-build843954301/os/exec/_test/exec.test 9 r M 1956 (0000000000d66dd1 854 00) 8192 0 /tmp/go-build843954301/os/exec/_test/exec.test 10 r M 1956 (0000000000d66dd1 854 00) 8192 0 /tmp/go-build843954301/os/exec/_test/exec.test 11 r c 0 (000000000000000f 0 00) 0 32 /dev/random 12 r M 1956 (0000000000d66dd1 854 00) 8192 0 /tmp/go-build843954301/os/exec/_test/exec.test 13 r c 0 (000000000000000a 0 00) 0 0 /dev/null 14 rw | 0 (0000000001df6801 0 00) 65536 0 #|/data 15 rw | 0 (0000000001df6802 0 00) 65536 1275 #|/data1 R=rsc, bradfitz, aram CC=golang-codereviews https://golang.org/cl/51420044 --- diff --git a/src/pkg/os/exec/exec_test.go b/src/pkg/os/exec/exec_test.go index 144fd46bcd..ad71503a83 100644 --- a/src/pkg/os/exec/exec_test.go +++ b/src/pkg/os/exec/exec_test.go @@ -480,6 +480,8 @@ func TestHelperProcess(*testing.T) { switch runtime.GOOS { case "dragonfly", "freebsd", "netbsd", "openbsd": ofcmd = "fstat" + case "plan9": + ofcmd = "/bin/cat" } args := os.Args @@ -570,6 +572,10 @@ func TestHelperProcess(*testing.T) { // the cloned file descriptors that result from opening // /dev/urandom. // http://golang.org/issue/3955 + case "plan9": + // TODO(0intro): Determine why Plan 9 is leaking + // file descriptors. + // http://golang.org/issue/7118 case "solaris": // TODO(aram): This fails on Solaris because libc opens // its own files, as it sees fit. Darwin does the same, @@ -585,7 +591,14 @@ func TestHelperProcess(*testing.T) { } if got := f.Fd(); got != wantfd { fmt.Printf("leaked parent file. fd = %d; want %d\n", got, wantfd) - out, _ := exec.Command(ofcmd, "-p", fmt.Sprint(os.Getpid())).CombinedOutput() + var args []string + switch runtime.GOOS { + case "plan9": + args = []string{fmt.Sprintf("/proc/%d/fd", os.Getpid())} + default: + args = []string{"-p", fmt.Sprint(os.Getpid())} + } + out, _ := exec.Command(ofcmd, args...).CombinedOutput() fmt.Print(string(out)) os.Exit(1) }