aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/exec_libc.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/syscall/exec_libc.go')
-rw-r--r--src/syscall/exec_libc.go42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/syscall/exec_libc.go b/src/syscall/exec_libc.go
index 0133139000..11cd2bb9f3 100644
--- a/src/syscall/exec_libc.go
+++ b/src/syscall/exec_libc.go
@@ -180,6 +180,27 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
}
}
+ // Detach fd 0 from tty
+ if sys.Noctty {
+ err1 = ioctl(0, uintptr(TIOCNOTTY), 0)
+ if err1 != 0 {
+ goto childerror
+ }
+ }
+
+ // Set the controlling TTY to Ctty
+ if sys.Setctty {
+ // On AIX, TIOCSCTTY is undefined
+ if TIOCSCTTY == 0 {
+ err1 = ENOSYS
+ goto childerror
+ }
+ err1 = 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 {
@@ -240,27 +261,6 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
close(uintptr(i))
}
- // Detach fd 0 from tty
- if sys.Noctty {
- err1 = ioctl(0, uintptr(TIOCNOTTY), 0)
- if err1 != 0 {
- goto childerror
- }
- }
-
- // Set the controlling TTY to Ctty
- if sys.Setctty {
- // On AIX, TIOCSCTTY is undefined
- if TIOCSCTTY == 0 {
- err1 = ENOSYS
- goto childerror
- }
- err1 = ioctl(uintptr(sys.Ctty), uintptr(TIOCSCTTY), 0)
- if err1 != 0 {
- goto childerror
- }
- }
-
// Time to exec.
err1 = execve(
uintptr(unsafe.Pointer(argv0)),