login_tty.c (116344) | login_tty.c (121193) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 18 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 18 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/lib/libutil/login_tty.c 116344 2003-06-14 18:42:37Z markm $"); | 35__FBSDID("$FreeBSD: head/lib/libutil/login_tty.c 121193 2003-10-18 10:04:16Z markm $"); |
36 37#if defined(LIBC_SCCS) && !defined(lint) 38#if 0 39static char sccsid[] = "@(#)login_tty.c 8.1 (Berkeley) 6/4/93"; 40#endif 41#endif /* LIBC_SCCS and not lint */ 42 43#include <sys/param.h> 44#include <sys/ioctl.h> 45 46#include <libutil.h> 47#include <stdlib.h> 48#include <unistd.h> 49 50int | 36 37#if defined(LIBC_SCCS) && !defined(lint) 38#if 0 39static char sccsid[] = "@(#)login_tty.c 8.1 (Berkeley) 6/4/93"; 40#endif 41#endif /* LIBC_SCCS and not lint */ 42 43#include <sys/param.h> 44#include <sys/ioctl.h> 45 46#include <libutil.h> 47#include <stdlib.h> 48#include <unistd.h> 49 50int |
51login_tty(fd) 52 int fd; | 51login_tty(int fd) |
53{ 54 (void) setsid(); 55 if (ioctl(fd, TIOCSCTTY, (char *)NULL) == -1) 56 return (-1); 57 (void) dup2(fd, 0); 58 (void) dup2(fd, 1); 59 (void) dup2(fd, 2); 60 if (fd > 2) 61 (void) close(fd); 62 return (0); 63} | 52{ 53 (void) setsid(); 54 if (ioctl(fd, TIOCSCTTY, (char *)NULL) == -1) 55 return (-1); 56 (void) dup2(fd, 0); 57 (void) dup2(fd, 1); 58 (void) dup2(fd, 2); 59 if (fd > 2) 60 (void) close(fd); 61 return (0); 62} |