143104Smarc /*- 2*61342Sbostic * Copyright (c) 1990, 1993 3*61342Sbostic * The Regents of the University of California. All rights reserved. 443104Smarc * 543104Smarc * %sccs.include.redist.c% 643104Smarc */ 743104Smarc 843104Smarc #if defined(LIBC_SCCS) && !defined(lint) 9*61342Sbostic static char sccsid[] = "@(#)login_tty.c 8.1 (Berkeley) 06/04/93"; 1043104Smarc #endif /* LIBC_SCCS and not lint */ 1143104Smarc 1243104Smarc #include <sys/param.h> 1343104Smarc #include <sys/ioctl.h> 1443104Smarc login_tty(fd)1543104Smarclogin_tty(fd) 1643104Smarc int fd; 1743104Smarc { 1843104Smarc (void) setsid(); 1943357Smarc if (ioctl(fd, TIOCSCTTY, (char *)NULL) == -1) 2043357Smarc return (-1); 2143104Smarc (void) dup2(fd, 0); 2243104Smarc (void) dup2(fd, 1); 2343104Smarc (void) dup2(fd, 2); 2443357Smarc if (fd > 2) 2543357Smarc (void) close(fd); 2643357Smarc return (0); 2743104Smarc } 28