.\" This replaces an earlier man page written by Walter Harms
.\" <walter.harms@informatik.uni-oldenburg.de>.
.\"
-.TH TTYSLOT 3 2016-03-15 "GNU" "Linux Programmer's Manual"
+.TH TTYSLOT 3 2017-09-15 "GNU" "Linux Programmer's Manual"
.SH NAME
ttyslot \- find the slot of the current user's terminal in some file
.SH SYNOPSIS
.BR "#include <unistd.h>" " /See NOTES */"
-.sp
+.PP
.B "int ttyslot(void);"
-.sp
+.PP
.in -4n
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.in
-.sp
+.PP
.ad l
.BR ttyslot ():
.RS 4
-Since glibc 2.20:
- _BSD_SOURCE ||
- _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_\ <\ 500
+Since glibc 2.24:
+ _DEFAULT_SOURCE
.br
-Glibc 2.19 and earlier:
+From glibc 2.20 to 2.23:
_DEFAULT_SOURCE ||
- _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_\ <\ 500
+ _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE\ <\ 500
+.br
+Glibc 2.19 and earlier:
+ _BSD_SOURCE ||
+ _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE\ <\ 500
.RE
.ad b
.SH DESCRIPTION
The legacy function
.BR ttyslot ()
returns the index of the current user's entry in some file.
-.LP
+.PP
Now "What file?" you ask.
Well, let's first look at some history.
.SS Ancient history
Thus a typical line was "18\-".
A hang on some line was solved by changing the \(aq1\(aq to a \(aq0\(aq,
signaling init, changing back again, and signaling init again.
-.LP
+.PP
In UNIX\ V7 the format was changed: here the second character
was the argument to
.BR getty (8)
300-1200-150-110 baud; \(aq4\(aq was for the on-line console DECwriter)
while the rest of the line contained the name of the tty.
Thus a typical line was "14console".
-.LP
+.PP
Later systems have more elaborate syntax.
System V-like systems have
.I /etc/inittab
.IR /etc/utmp ,
.IR /var/adm/utmp ,
.IR /var/run/utmp .
-.LP
+.PP
The glibc2 implementation of this function reads the file
.BR _PATH_TTYS ,
defined in
.BR ttyslot ()
is provided by
.IR <unistd.h> .
-On Systsem V-like systems, the declaration is provided by
+On System V-like systems, the declaration is provided by
.IR <stdlib.h> .
Since glibc 2.24,
-.IR <stdlib.h>
+.I <stdlib.h>
also provides the declaration with the following
feature test macro definitions:
.PP
-.nf
.in +4n
+.EX
(_XOPEN_SOURCE >= 500 ||
(_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED))
&& ! (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
+.EE
.in
-.fi
.PP
Minix also has
.IR fttyslot ( fd ).