isatty(3)
is a library function (you won't find anything about in the linux kernel), and is usually implemented by calling tcgetattr(3)
and checking its return value.
For example, in the GNU C library (glibc):
/* Return 1 if FD is a terminal, 0 if not. */
int
__isatty (int fd)
{
struct termios term;
return __tcgetattr (fd, &term) == 0;
}
tcgetattr(3)
itself will resolve to some ioctl like TCGETA
or TCGETS
.
Notice that isatty(3)
will also return true for a master side of a pseudo-tty, which isn't really a tty -- most tty related ops performed on it will actually apply to its slave side.
On linux, isatty(3)
will also return true for /dev/console
, which again, isn't a real tty (it cannot be made the controlling tty of a process).
On linux, you can obtain a list of all the tty drivers on your system with their major and minor numbers via cat /proc/tty/drivers
. Of course, that only reflects the modules which have been loaded.