• Last 5 Forum Topics
    Last post

The Web Only This Site



  • MARC

    Mailing list ARChives
    - Search by -


    Computing Dictionary

  • Text Link Ads

  • LINUX man pages
  • Linux Man Page Viewer

    The following form allows you to view linux man pages.





           #include <unistd.h>    /* on BSD-like systems, and Linux */
           #include <stdlib.h>    /* on System V-like systems */
           int ttyslot(void);
       Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
               _BSD_SOURCE ||


           The  legacy  function ttyslot() returns the index of the current user's
           entry in some file.
           Now "What file?" you ask.  Well, let's first look at some history.
       Ancient history
           There used to be a file /etc/ttys in UNIX V6,  that  was  read  by  the
           init(8)  program  to find out what to do with each terminal line.  Each
           line consisted of three characters.  The first character was either '0'
           or  '1',  where  '0'  meant "ignore".  The second character denoted the
           terminal: '8' stood for "/dev/tty8".  The third character was an  argu-
           ment  to  getty(8)  indicating  the sequence of line speeds to try ('-'
           was: start trying 110 baud).  Thus a typical line was "18-".  A hang on
           some  line  was  solved  by  changing the '1' to a '0', signaling init,
           changing back again, and signaling init again.
           In UNIX V7 the format was changed: here the second  character  was  the
           argument to getty(8) indicating the sequence of line speeds to try ('0'
           was: cycle through 300-1200-150-110 baud; '4' was for the on-line  con-
           sole  DECwriter)  while  the rest of the line contained the name of the
           tty.  Thus a typical line was "14console".
           Later systems have more elaborate syntax.  System V-like  systems  have
           /etc/inittab instead.
       Ancient history (2)
           On  the other hand, there is the file /etc/utmp listing the people cur-
           rently logged in.  It is maintained by login(1).  It has a fixed  size,
           and  the appropriate index in the file was determined by login(1) using
           the ttyslot() call to find the number of the line in /etc/ttys  (count-
           ing from 1).
       The semantics of ttyslot
           Thus,  the function ttyslot() returns the index of the controlling ter-
           minal of the calling process in the file /etc/ttys, and that  is  (usu-
           ally)  the  same  as the index of the entry for the current user in the
           file /etc/utmp.  BSD still has the /etc/ttys file,  but  System  V-like
           systems  do  not,  and hence cannot refer to it.  Thus, on such systems
           the documentation says that ttyslot() returns the current user's  index
           SUSv1;  marked  as  LEGACY  in  SUSv2;  removed in POSIX.1-2001.  SUSv2
           requires -1 on error.


           The utmp file is found various  places  on  various  systems,  such  as
           /etc/utmp, /var/adm/utmp, /var/run/utmp.
           The  glibc2  implementation of this function reads the file _PATH_TTYS,
           defined in <ttyent.h> as "/etc/ttys".  It returns 0  on  error.   Since
           Linux systems do not usually have "/etc/ttys", it will always return 0.
           Minix also has fttyslot(fd).


           getttyent(3), ttyname(3), utmp(5)

    GNU 2013-07-22 TTYSLOT(3)


  • Linux

    The Distributions


    The Software


    The News


  • Toll Free
Copyright © 1999 - 2016 by LinuxGuruz