mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-21 01:12:26 +08:00
* misc/login_tty.c [! TIOCSCTTY]: Try an emulation using ttyname
and open.
This commit is contained in:
parent
4bca5a35b8
commit
c0fef53b1e
@ -1,5 +1,8 @@
|
||||
Wed Apr 5 00:13:45 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
||||
|
||||
* misc/login_tty.c [! TIOCSCTTY]: Try an emulation using ttyname
|
||||
and open.
|
||||
|
||||
* sysdeps/i386/bsd-_setjmp.S: Fix typo in name: setjmp -> _setjmp.
|
||||
|
||||
Tue Apr 4 00:48:53 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user