forkpty: set the output fd to -1 on the slave side.

glibc, FreeBSD, OpenBSD, and Darwin all just leave the fd unchanged and
possibly uninitialized. Setting it to -1 seems friendlier, though.

Bug: http://b/27506278
Change-Id: I7acdc8eecbea4404d5fb4ba0b4d572245a323886
diff --git a/libc/bionic/pty.cpp b/libc/bionic/pty.cpp
index 1a37847..d699ff5 100644
--- a/libc/bionic/pty.cpp
+++ b/libc/bionic/pty.cpp
@@ -151,22 +151,24 @@
   return 0;
 }
 
-int forkpty(int* master, char* name, const termios* t, const winsize* ws) {
+int forkpty(int* amaster, char* name, const termios* t, const winsize* ws) {
+  int master;
   int slave;
-  if (openpty(master, &slave, name, t, ws) == -1) {
+  if (openpty(&master, &slave, name, t, ws) == -1) {
     return -1;
   }
 
   pid_t pid = fork();
   if (pid == -1) {
-    close(*master);
+    close(master);
     close(slave);
     return -1;
   }
 
   if (pid == 0) {
     // Child.
-    close(*master);
+    *amaster = -1;
+    close(master);
     if (login_tty(slave) == -1) {
       _exit(1);
     }
@@ -174,6 +176,7 @@
   }
 
   // Parent.
+  *amaster = master;
   close(slave);
   return pid;
 }