Skip to content

Commit 2711127

Browse files
committed
syscall: avoid dup2 in forkAndExecInChild1 on Android
Android O and newer blocks the dup2 syscall. Change-Id: Ibca01fc72ef114deeef6c0450a8b81a556ed0530 Reviewed-on: https://go-review.googlesource.com/c/go/+/235537 Run-TryBot: Elias Naur <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 6bf2eea commit 2711127

11 files changed

+28
-36
lines changed

src/syscall/syscall_dup2_linux.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2020 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build !android
6+
// +build 386 amd64 arm mips mipsle mips64 mips64le ppc64 ppc64le s390x
7+
8+
package syscall
9+
10+
const _SYS_dup = SYS_DUP2

src/syscall/syscall_dup3_linux.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright 2020 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build android arm64 riscv64
6+
7+
package syscall
8+
9+
const _SYS_dup = SYS_DUP3

src/syscall/syscall_linux_386.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ package syscall
99

1010
import "unsafe"
1111

12-
const (
13-
_SYS_dup = SYS_DUP2
14-
_SYS_setgroups = SYS_SETGROUPS32
15-
)
12+
const _SYS_setgroups = SYS_SETGROUPS32
1613

1714
func setTimespec(sec, nsec int64) Timespec {
1815
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}

src/syscall/syscall_linux_amd64.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
package syscall
66

7-
const (
8-
_SYS_dup = SYS_DUP2
9-
_SYS_setgroups = SYS_SETGROUPS
10-
)
7+
const _SYS_setgroups = SYS_SETGROUPS
118

129
//sys Dup2(oldfd int, newfd int) (err error)
1310
//sysnb EpollCreate(size int) (fd int, err error)

src/syscall/syscall_linux_arm.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ package syscall
66

77
import "unsafe"
88

9-
const (
10-
_SYS_dup = SYS_DUP2
11-
_SYS_setgroups = SYS_SETGROUPS32
12-
)
9+
const _SYS_setgroups = SYS_SETGROUPS32
1310

1411
func setTimespec(sec, nsec int64) Timespec {
1512
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}

src/syscall/syscall_linux_arm64.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ package syscall
66

77
import "unsafe"
88

9-
const (
10-
_SYS_dup = SYS_DUP3
11-
_SYS_setgroups = SYS_SETGROUPS
12-
)
9+
const _SYS_setgroups = SYS_SETGROUPS
1310

1411
func EpollCreate(size int) (fd int, err error) {
1512
if size <= 0 {

src/syscall/syscall_linux_mips64x.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77

88
package syscall
99

10-
const (
11-
_SYS_dup = SYS_DUP2
12-
_SYS_setgroups = SYS_SETGROUPS
13-
)
10+
const _SYS_setgroups = SYS_SETGROUPS
1411

1512
//sys Dup2(oldfd int, newfd int) (err error)
1613
//sysnb EpollCreate(size int) (fd int, err error)

src/syscall/syscall_linux_mipsx.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ package syscall
99

1010
import "unsafe"
1111

12-
const (
13-
_SYS_dup = SYS_DUP2
14-
_SYS_setgroups = SYS_SETGROUPS
15-
)
12+
const _SYS_setgroups = SYS_SETGROUPS
1613

1714
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno)
1815

src/syscall/syscall_linux_ppc64x.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77

88
package syscall
99

10-
const (
11-
_SYS_dup = SYS_DUP2
12-
_SYS_setgroups = SYS_SETGROUPS
13-
)
10+
const _SYS_setgroups = SYS_SETGROUPS
1411

1512
//sys Dup2(oldfd int, newfd int) (err error)
1613
//sysnb EpollCreate(size int) (fd int, err error)

src/syscall/syscall_linux_riscv64.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ package syscall
66

77
import "unsafe"
88

9-
const (
10-
_SYS_dup = SYS_DUP3
11-
_SYS_setgroups = SYS_SETGROUPS
12-
)
9+
const _SYS_setgroups = SYS_SETGROUPS
1310

1411
func EpollCreate(size int) (fd int, err error) {
1512
if size <= 0 {

src/syscall/syscall_linux_s390x.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ package syscall
66

77
import "unsafe"
88

9-
const (
10-
_SYS_dup = SYS_DUP2
11-
_SYS_setgroups = SYS_SETGROUPS
12-
)
9+
const _SYS_setgroups = SYS_SETGROUPS
1310

1411
//sys Dup2(oldfd int, newfd int) (err error)
1512
//sysnb EpollCreate(size int) (fd int, err error)

0 commit comments

Comments
 (0)