]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: exec_linux.go: support platforms without SYS_DUP2
authorDave Cheney <dave@cheney.net>
Sun, 8 Mar 2015 20:03:00 +0000 (07:03 +1100)
committerDave Cheney <dave@cheney.net>
Tue, 10 Mar 2015 22:52:09 +0000 (22:52 +0000)
Updates #9974

This change is in preparation for merging the arm64 platform.

Arm64 does not support SYS_DUP2 at all, so define a new constant to be
the minimum dup(2) version supported. This constant defaults to SYS_DUP2
on all existing platforms.

Change-Id: If405878105082c7c880f8541c1491970124c9ce4
Reviewed-on: https://go-review.googlesource.com/7123
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
src/syscall/exec_linux.go
src/syscall/syscall_linux_386.go
src/syscall/syscall_linux_amd64.go
src/syscall/syscall_linux_arm.go
src/syscall/syscall_linux_ppc64x.go

index 03dd5c53c494497b3d99c208298c0c25299ff83e..2e0577cecc20856afbc7b26cbc22b529db1671b8 100644 (file)
@@ -214,7 +214,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
        // Pass 1: look for fd[i] < i and move those up above len(fd)
        // so that pass 2 won't stomp on an fd it needs later.
        if pipe < nextfd {
-               _, _, err1 = RawSyscall(SYS_DUP2, uintptr(pipe), uintptr(nextfd), 0)
+               _, _, err1 = RawSyscall(_SYS_dup, uintptr(pipe), uintptr(nextfd), 0)
                if err1 != 0 {
                        goto childerror
                }
@@ -224,7 +224,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
        }
        for i = 0; i < len(fd); i++ {
                if fd[i] >= 0 && fd[i] < int(i) {
-                       _, _, err1 = RawSyscall(SYS_DUP2, uintptr(fd[i]), uintptr(nextfd), 0)
+                       _, _, err1 = RawSyscall(_SYS_dup, uintptr(fd[i]), uintptr(nextfd), 0)
                        if err1 != 0 {
                                goto childerror
                        }
@@ -254,7 +254,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
                }
                // The new fd is created NOT close-on-exec,
                // which is exactly what we want.
-               _, _, err1 = RawSyscall(SYS_DUP2, uintptr(fd[i]), uintptr(i), 0)
+               _, _, err1 = RawSyscall(_SYS_dup, uintptr(fd[i]), uintptr(i), 0)
                if err1 != 0 {
                        goto childerror
                }
index 0dcc6be2e943f08be71fb1f384ba4ca1f1e9a41a..61ff233ddc9eaaa1e7fb308cf6ad3a685388839d 100644 (file)
@@ -9,6 +9,8 @@ package syscall
 
 import "unsafe"
 
+const _SYS_dup = SYS_DUP2
+
 func Getpagesize() int { return 4096 }
 
 func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
index 8d0777c7131bb6554932e22a73fc5c67048eec65..ff00ed549a6688f08356b37aab9e1a4f678bb773 100644 (file)
@@ -4,6 +4,8 @@
 
 package syscall
 
+const _SYS_dup = SYS_DUP2
+
 //sysnb        Dup2(oldfd int, newfd int) (err error)
 //sys  Fchown(fd int, uid int, gid int) (err error)
 //sys  Fstat(fd int, stat *Stat_t) (err error)
index ebbaa17eabb90d3a4bd3d71c77821e2851fe3364..862c01c24d4dcc943b21339669759d06732c56c0 100644 (file)
@@ -6,6 +6,8 @@ package syscall
 
 import "unsafe"
 
+const _SYS_dup = SYS_DUP2
+
 func Getpagesize() int { return 4096 }
 
 func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
index c266c855e28a2406a844d451b5401f7fd816d5c5..fcf1d7b178d348feffe6096e8b98d064453d8c04 100644 (file)
@@ -7,6 +7,8 @@
 
 package syscall
 
+const _SYS_dup = SYS_DUP2
+
 //sysnb        Dup2(oldfd int, newfd int) (err error)
 //sys  Fchown(fd int, uid int, gid int) (err error)
 //sys  Fstat(fd int, stat *Stat_t) (err error)