]> Cypherpunks repositories - gostls13.git/commitdiff
os,syscall: fix windows build
authorBrad Fitzpatrick <bradfitz@golang.org>
Fri, 10 Feb 2012 21:47:19 +0000 (08:47 +1100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 10 Feb 2012 21:47:19 +0000 (08:47 +1100)
make syscall.ProcAttr.Files be []uintptr

all.bash passes on Linux.
things seem to compile on GOOS={darwin,windows}

R=golang-dev, mattn.jp, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/5653055

src/pkg/net/sendfile_windows.go
src/pkg/os/exec/exec_test.go
src/pkg/os/exec_posix.go
src/pkg/os/file_windows.go
src/pkg/syscall/exec_bsd.go
src/pkg/syscall/exec_linux.go
src/pkg/syscall/exec_unix.go
src/pkg/syscall/exec_windows.go

index ee7ff8b98c2d9849f4905610d22a13d3955a9c81..c247477d5af7769bd2b369a5f196d7bb50d40d67 100644 (file)
@@ -56,7 +56,7 @@ func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) {
        var o sendfileOp
        o.Init(c, 'w')
        o.n = uint32(n)
-       o.src = f.Fd()
+       o.src = syscall.Handle(f.Fd())
        done, err := iosrv.ExecIO(&o, 0)
        if err != nil {
                return 0, err, false
index 2e4bef5119f6093ca1e3a53d3225bc46c4f3c783..52f4bce3aea3f495e22d38ea997d983187489613 100644 (file)
@@ -17,7 +17,6 @@ import (
        "runtime"
        "strconv"
        "strings"
-       "syscall"
        "testing"
 )
 
@@ -153,8 +152,8 @@ func TestExtraFiles(t *testing.T) {
 
        // Ensure that file descriptors have not already been leaked into
        // our environment.
-       for fd := int(os.Stderr.Fd()) + 1; fd <= 101; fd++ {
-               err := syscall.Close(fd)
+       for fd := os.Stderr.Fd() + 1; fd <= 101; fd++ {
+               err := os.NewFile(fd, "").Close()
                if err == nil {
                        t.Logf("Something already leaked - closed fd %d", fd)
                }
index df283f1c02429b41789e11e57f40d33da4728bb9..d5429849bf20c4075053fd71f0b266511ed3bd3f 100644 (file)
@@ -38,7 +38,7 @@ func StartProcess(name string, argv []string, attr *ProcAttr) (p *Process, err e
                sysattr.Env = Environ()
        }
        for _, f := range attr.Files {
-               sysattr.Files = append(sysattr.Files, int(f.Fd()))
+               sysattr.Files = append(sysattr.Files, f.Fd())
        }
 
        pid, h, e := syscall.StartProcess(name, argv, sysattr)
index 7f263c80cd12bfa390339bc5b23a1fc0521b5d8d..350d2a72cf98ddda196d04c93f57c7ba2086ca7e 100644 (file)
@@ -70,7 +70,7 @@ func openFile(name string, flag int, perm FileMode) (file *File, err error) {
                syscall.CloseOnExec(r)
        }
 
-       return NewFile(r, name), nil
+       return NewFile(uintptr(r), name), nil
 }
 
 func openDir(name string) (file *File, err error) {
@@ -79,7 +79,7 @@ func openDir(name string) (file *File, err error) {
        if e != nil {
                return nil, &PathError{"open", name, e}
        }
-       f := NewFile(r, name)
+       f := NewFile(uintptr(r), name)
        f.dirinfo = d
        return f, nil
 }
@@ -313,7 +313,7 @@ func Pipe() (r *File, w *File, err error) {
        syscall.CloseOnExec(p[1])
        syscall.ForkLock.RUnlock()
 
-       return NewFile(p[0], "|0"), NewFile(p[1], "|1"), nil
+       return NewFile(uintptr(p[0]), "|0"), NewFile(uintptr(p[1]), "|1"), nil
 }
 
 // TempDir returns the default directory to use for temporary files.
index fc72c9af8ce9d49f1a31066ee096441ddb3a375b..9c3af5ec955bd1a5958712bf502ea6792ffdcf31 100644 (file)
@@ -39,8 +39,10 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
                i      int
        )
 
-       // guard against side effects of shuffling fds below.
-       fd := append([]int(nil), attr.Files...)
+       fd := make([]int, len(attr.Files))
+       for i, ufd := range attr.Files {
+               fd[i] = int(ufd)
+       }
 
        darwin := runtime.GOOS == "darwin"
 
index 38b8f9e3571d3dbee33e698231bb4a95d4525b55..b9ce3676e4c9953629dfd515f0230cdae27185c3 100644 (file)
@@ -40,7 +40,10 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
        )
 
        // guard against side effects of shuffling fds below.
-       fd := append([]int(nil), attr.Files...)
+       fd := make([]int, len(attr.Files))
+       for i, ufd := range attr.Files {
+               fd[i] = int(ufd)
+       }
 
        // About to call fork.
        // No more allocation or calls of non-assembly functions.
index b70e1880b9623e40d1adf8aadc897a452b944226..dfaa0374a5327a066ed9b23bf360e8008f2f60cb 100644 (file)
@@ -101,9 +101,9 @@ type Credential struct {
 // ProcAttr holds attributes that will be applied to a new process started
 // by StartProcess.
 type ProcAttr struct {
-       Dir   string   // Current working directory.
-       Env   []string // Environment.
-       Files []int    // File descriptors.
+       Dir   string    // Current working directory.
+       Env   []string  // Environment.
+       Files []uintptr // File descriptors.
        Sys   *SysProcAttr
 }
 
index 6cb25a7d00a9362bbfca5641eebe89bfca3b1042..4dc4d059d7e307bf16e376b5e22651fdeaff9045 100644 (file)
@@ -220,7 +220,7 @@ func joinExeDirAndFName(dir, p string) (name string, err error) {
 type ProcAttr struct {
        Dir   string
        Env   []string
-       Files []Handle
+       Files []uintptr
        Sys   *SysProcAttr
 }