mirror of
https://github.com/golang/go
synced 2024-11-12 07:10:22 -07:00
os,syscall: fix windows build
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
This commit is contained in:
parent
09f6a49194
commit
fbab6d8512
@ -56,7 +56,7 @@ func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) {
|
|||||||
var o sendfileOp
|
var o sendfileOp
|
||||||
o.Init(c, 'w')
|
o.Init(c, 'w')
|
||||||
o.n = uint32(n)
|
o.n = uint32(n)
|
||||||
o.src = f.Fd()
|
o.src = syscall.Handle(f.Fd())
|
||||||
done, err := iosrv.ExecIO(&o, 0)
|
done, err := iosrv.ExecIO(&o, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err, false
|
return 0, err, false
|
||||||
|
@ -17,7 +17,6 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -153,8 +152,8 @@ func TestExtraFiles(t *testing.T) {
|
|||||||
|
|
||||||
// Ensure that file descriptors have not already been leaked into
|
// Ensure that file descriptors have not already been leaked into
|
||||||
// our environment.
|
// our environment.
|
||||||
for fd := int(os.Stderr.Fd()) + 1; fd <= 101; fd++ {
|
for fd := os.Stderr.Fd() + 1; fd <= 101; fd++ {
|
||||||
err := syscall.Close(fd)
|
err := os.NewFile(fd, "").Close()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Logf("Something already leaked - closed fd %d", fd)
|
t.Logf("Something already leaked - closed fd %d", fd)
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func StartProcess(name string, argv []string, attr *ProcAttr) (p *Process, err e
|
|||||||
sysattr.Env = Environ()
|
sysattr.Env = Environ()
|
||||||
}
|
}
|
||||||
for _, f := range attr.Files {
|
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)
|
pid, h, e := syscall.StartProcess(name, argv, sysattr)
|
||||||
|
@ -70,7 +70,7 @@ func openFile(name string, flag int, perm FileMode) (file *File, err error) {
|
|||||||
syscall.CloseOnExec(r)
|
syscall.CloseOnExec(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewFile(r, name), nil
|
return NewFile(uintptr(r), name), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func openDir(name string) (file *File, err error) {
|
func openDir(name string) (file *File, err error) {
|
||||||
@ -79,7 +79,7 @@ func openDir(name string) (file *File, err error) {
|
|||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, &PathError{"open", name, e}
|
return nil, &PathError{"open", name, e}
|
||||||
}
|
}
|
||||||
f := NewFile(r, name)
|
f := NewFile(uintptr(r), name)
|
||||||
f.dirinfo = d
|
f.dirinfo = d
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
@ -313,7 +313,7 @@ func Pipe() (r *File, w *File, err error) {
|
|||||||
syscall.CloseOnExec(p[1])
|
syscall.CloseOnExec(p[1])
|
||||||
syscall.ForkLock.RUnlock()
|
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.
|
// TempDir returns the default directory to use for temporary files.
|
||||||
|
@ -39,8 +39,10 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
|
|||||||
i int
|
i int
|
||||||
)
|
)
|
||||||
|
|
||||||
// guard against side effects of shuffling fds below.
|
fd := make([]int, len(attr.Files))
|
||||||
fd := append([]int(nil), attr.Files...)
|
for i, ufd := range attr.Files {
|
||||||
|
fd[i] = int(ufd)
|
||||||
|
}
|
||||||
|
|
||||||
darwin := runtime.GOOS == "darwin"
|
darwin := runtime.GOOS == "darwin"
|
||||||
|
|
||||||
|
@ -40,7 +40,10 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
|
|||||||
)
|
)
|
||||||
|
|
||||||
// guard against side effects of shuffling fds below.
|
// 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.
|
// About to call fork.
|
||||||
// No more allocation or calls of non-assembly functions.
|
// No more allocation or calls of non-assembly functions.
|
||||||
|
@ -101,9 +101,9 @@ type Credential struct {
|
|||||||
// ProcAttr holds attributes that will be applied to a new process started
|
// ProcAttr holds attributes that will be applied to a new process started
|
||||||
// by StartProcess.
|
// by StartProcess.
|
||||||
type ProcAttr struct {
|
type ProcAttr struct {
|
||||||
Dir string // Current working directory.
|
Dir string // Current working directory.
|
||||||
Env []string // Environment.
|
Env []string // Environment.
|
||||||
Files []int // File descriptors.
|
Files []uintptr // File descriptors.
|
||||||
Sys *SysProcAttr
|
Sys *SysProcAttr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ func joinExeDirAndFName(dir, p string) (name string, err error) {
|
|||||||
type ProcAttr struct {
|
type ProcAttr struct {
|
||||||
Dir string
|
Dir string
|
||||||
Env []string
|
Env []string
|
||||||
Files []Handle
|
Files []uintptr
|
||||||
Sys *SysProcAttr
|
Sys *SysProcAttr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user