about summary refs log tree commit diff
path: root/misc
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-04-05 04:39:51 +0000
committerRoland McGrath <roland@gnu.org>1995-04-05 04:39:51 +0000
commitc0fef53b1e038a29ea57825af88fceeebdab874e (patch)
tree1695cfe07d507f907b5906af50614e0a9f7e3683 /misc
parent4bca5a35b82dd45f3322679ef900a1753fc8d688 (diff)
downloadglibc-c0fef53b1e038a29ea57825af88fceeebdab874e.tar.gz
glibc-c0fef53b1e038a29ea57825af88fceeebdab874e.tar.xz
glibc-c0fef53b1e038a29ea57825af88fceeebdab874e.zip
* misc/login_tty.c [! TIOCSCTTY]: Try an emulation using ttyname
 	and open.
Diffstat (limited to 'misc')
-rw-r--r--misc/login_tty.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/misc/login_tty.c b/misc/login_tty.c
index 6ea2b9b07f..e4e075c6ed 100644
--- a/misc/login_tty.c
+++ b/misc/login_tty.c
@@ -38,14 +38,34 @@ static char sccsid[] = "@(#)login_tty.c	8.1 (Berkeley) 6/4/93";
 #include <sys/param.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
+#include <fcntl.h>
 
 int
 login_tty(fd)
 	int fd;
 {
 	(void) setsid();
+#ifdef TIOCSCTTY
 	if (ioctl(fd, TIOCSCTTY, (char *)NULL) == -1)
 		return (-1);
+#else
+	{
+	  /* This might work.  */
+	  char *fdname = ttyname (fd);
+	  int newfd;
+	  if (fdname)
+	    {
+	      if (fd != 0)
+		(void) close (0);
+	      if (fd != 1)
+		(void) close (1);
+	      if (fd != 2)
+		(void) close (2);
+	      newfd = open (fdname, O_RDWR);
+	      (void) close (newfd);
+	    }
+	}
+#endif
 	(void) dup2(fd, 0);
 	(void) dup2(fd, 1);
 	(void) dup2(fd, 2);