1 .\"
   2 .\" Copyright 2015 Nexenta Systems, Inc. All Rights Reserved. 
   3 .\" Copyright (c) 1996 Joerg Wunsch
   4 .\"
   5 .\" All rights reserved.
   6 .\"
   7 .\" Redistribution and use in source and binary forms, with or without
   8 .\" modification, are permitted provided that the following conditions
   9 .\" are met:
  10 .\" 1. Redistributions of source code must retain the above copyright
  11 .\"    notice, this list of conditions and the following disclaimer.
  12 .\" 2. Redistributions in binary form must reproduce the above copyright
  13 .\"    notice, this list of conditions and the following disclaimer in the
  14 .\"    documentation and/or other materials provided with the distribution.
  15 .\"
  16 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
  17 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
  20 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26 .\"
  27 .\" "
  28 .Dd October 10, 2015
  29 .Dt LOGIN_TTY 3
  30 .Os
  31 .Sh NAME
  32 .Nm login_tty
  33 .Nd prepare a tty for a new login session
  34 .Sh SYNOPSIS
  35 .In pty.h
  36 .Ft int
  37 .Fn login_tty "int fd"
  38 .Sh DESCRIPTION
  39 The function
  40 .Fn login_tty
  41 prepares a terminal for a new login session.
  42 The file descriptor
  43 .Ar fd
  44 passed to
  45 .Fn login_tty
  46 must be opened for reading and writing on a terminal device.
  47 It will be
  48 made the controlling terminal for the calling process, after allocating
  49 a new session with
  50 .Xr setsid 2 .
  51 This terminal device will also be made the standard input, standard output,
  52 and standard error output of the calling process.
  53 .Sh RETURN VALUES
  54 The function returns -1 if
  55 .Fn setsid
  56 fails or
  57 .Fn login_tty
  58 could not make the device referenced by
  59 .Ar fd
  60 the controlling terminal of the calling process, and 0 otherwise.
  61 .Sh INTERFACE STABILITY
  62 .Sy Comitted
  63 .Sh MT-LEVEL
  64 .Sy Unsafe
  65 .Sh SEE ALSO
  66 .Xr dup2 3 ,
  67 .Xr ioctl 2 ,
  68 .Xr setsid 2 ,
  69 .Xr tty 1