1ISATTY(3) Linux Programmer's Manual ISATTY(3)
2
3
4
6 isatty - test whether a file descriptor refers to a terminal
7
9 #include <unistd.h>
10
11 int isatty(int fd);
12
14 The isatty() function tests whether fd is an open file descriptor
15 referring to a terminal.
16
18 isatty() returns 1 if fd is an open file descriptor referring to a ter‐
19 minal; otherwise 0 is returned, and errno is set to indicate the error.
20
22 EBADF fd is not a valid file descriptor.
23
24 ENOTTY fd refers to a file other than a terminal. On some older ker‐
25 nels, some types of files resulted in the error EINVAL in this
26 case (which is a violation of POSIX, which specifies the error
27 ENOTTY).
28
30 For an explanation of the terms used in this section, see
31 attributes(7).
32
33 ┌──────────┬───────────────┬─────────┐
34 │Interface │ Attribute │ Value │
35 ├──────────┼───────────────┼─────────┤
36 │isatty() │ Thread safety │ MT-Safe │
37 └──────────┴───────────────┴─────────┘
39 POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
40
42 fstat(2), ttyname(3)
43
45 This page is part of release 5.02 of the Linux man-pages project. A
46 description of the project, information about reporting bugs, and the
47 latest version of this page, can be found at
48 https://www.kernel.org/doc/man-pages/.
49
50
51
52Linux 2019-03-06 ISATTY(3)