aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/exec_bsd.go
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2019-06-26 17:09:14 +0000
committerDamien Neil <dneil@google.com>2019-06-27 16:53:02 +0000
commite301e165ac3bd591a2c8b52dcc5bdd2b0ef68191 (patch)
tree8e5d284291d28d8fdb241c142e4297f05ffac629 /src/syscall/exec_bsd.go
parent998a98984b5b32a0cab53e0fd690b5a01683db6a (diff)
downloadgo-e301e165ac3bd591a2c8b52dcc5bdd2b0ef68191.tar.xz
Revert "syscall: use Ctty before fd shuffle"
This reverts commit 103b5b66921b351f8db4fc6e83bf147b1a0d7580. Reason for revert: Breaks valid existing programs. Updates #29458 Change-Id: I7ace4ae404cf2a8b0e15e646663c50115f74b758 Reviewed-on: https://go-review.googlesource.com/c/go/+/183939 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Greg Thelen <gthelen@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/syscall/exec_bsd.go')
-rw-r--r--src/syscall/exec_bsd.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/syscall/exec_bsd.go b/src/syscall/exec_bsd.go
index 632b711ce8..30b88eba7a 100644
--- a/src/syscall/exec_bsd.go
+++ b/src/syscall/exec_bsd.go
@@ -162,22 +162,6 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
}
}
- // Detach fd 0 from tty
- if sys.Noctty {
- _, _, err1 = RawSyscall(SYS_IOCTL, 0, uintptr(TIOCNOTTY), 0)
- if err1 != 0 {
- goto childerror
- }
- }
-
- // Set the controlling TTY to Ctty
- if sys.Setctty {
- _, _, err1 = RawSyscall(SYS_IOCTL, uintptr(sys.Ctty), uintptr(TIOCSCTTY), 0)
- if err1 != 0 {
- goto childerror
- }
- }
-
// 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 {
@@ -235,6 +219,22 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
RawSyscall(SYS_CLOSE, uintptr(i), 0, 0)
}
+ // Detach fd 0 from tty
+ if sys.Noctty {
+ _, _, err1 = RawSyscall(SYS_IOCTL, 0, uintptr(TIOCNOTTY), 0)
+ if err1 != 0 {
+ goto childerror
+ }
+ }
+
+ // Set the controlling TTY to Ctty
+ if sys.Setctty {
+ _, _, err1 = RawSyscall(SYS_IOCTL, uintptr(sys.Ctty), uintptr(TIOCSCTTY), 0)
+ if err1 != 0 {
+ goto childerror
+ }
+ }
+
// Time to exec.
_, _, err1 = RawSyscall(SYS_EXECVE,
uintptr(unsafe.Pointer(argv0)),