syscall: TIOCSCTTY does not exist on AIX

Issue golang/go#19200

Change-Id: I09a94e90c20c2c2e19a2330834141a762d76a24b
Reviewed-on: https://go-review.googlesource.com/38254
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/libgo/go/syscall/exec_bsd.go b/libgo/go/syscall/exec_bsd.go
index af025e4..80991ec 100644
--- a/libgo/go/syscall/exec_bsd.go
+++ b/libgo/go/syscall/exec_bsd.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd netbsd openbsd solaris
 
 package syscall
 
@@ -235,6 +235,10 @@
 
 	// Set the controlling TTY to Ctty
 	if sys.Setctty {
+		if TIOCSCTTY == 0 {
+			err1 = ENOSYS
+			goto childerror
+		}
 		_, err1 = raw_ioctl(sys.Ctty, TIOCSCTTY, 0)
 		if err1 != 0 {
 			goto childerror
diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh
index 6bc78bd..72434d5 100755
--- a/libgo/mksysinfo.sh
+++ b/libgo/mksysinfo.sh
@@ -876,6 +876,11 @@
   fi
 fi
 
+# If nothing else defined TIOCSCTTY, make sure it has a value.
+if ! grep "const TIOCSCTTY " ${OUT} >/dev/null 2>&1; then
+  echo "const TIOCSCTTY = 0" >> ${OUT}
+fi
+
 # The nlmsghdr struct.
 grep '^type _nlmsghdr ' gen-sysinfo.go | \
     sed -e 's/_nlmsghdr/NlMsghdr/' \