1isatty(3) Library Functions Manual isatty(3)
2
3
4
6 isatty - test whether a file descriptor refers to a terminal
7
9 Standard C library (libc, -lc)
10
12 #include <unistd.h>
13
14 int isatty(int fd);
15
17 The isatty() function tests whether fd is an open file descriptor re‐
18 ferring to a terminal.
19
21 isatty() returns 1 if fd is an open file descriptor referring to a ter‐
22 minal; otherwise 0 is returned, and errno is set to indicate the error.
23
25 EBADF fd is not a valid file descriptor.
26
27 ENOTTY fd refers to a file other than a terminal. On some older ker‐
28 nels, some types of files resulted in the error EINVAL in this
29 case (which is a violation of POSIX, which specifies the error
30 ENOTTY).
31
33 For an explanation of the terms used in this section, see at‐
34 tributes(7).
35
36 ┌────────────────────────────────────────────┬───────────────┬─────────┐
37 │Interface │ Attribute │ Value │
38 ├────────────────────────────────────────────┼───────────────┼─────────┤
39 │isatty() │ Thread safety │ MT-Safe │
40 └────────────────────────────────────────────┴───────────────┴─────────┘
41
43 POSIX.1-2008.
44
46 POSIX.1-2001, SVr4, 4.3BSD.
47
49 fstat(2), ttyname(3)
50
51
52
53Linux man-pages 6.04 2023-03-30 isatty(3)