Debian Codegraph @

upstream/debian-unstable/man3/isatty.3

raw
1 '\" t
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH isatty 3 2025-05-17 "Linux man-pages 6.18"
7 .SH NAME
8 isatty \- test whether a file descriptor refers to a terminal
9 .SH LIBRARY
10 Standard C library
11 .RI ( libc ,\~ \-lc )
12 .SH SYNOPSIS
13 .nf
14 .B #include <unistd.h>
15 .P
16 .BI "int isatty(int " fd );
17 .fi
18 .SH DESCRIPTION
19 The
20 .BR isatty ()
21 function tests whether
22 .I fd
23 is an open file descriptor referring to a terminal.
24 .SH RETURN VALUE
25 .BR isatty ()
26 returns 1 if
27 .I fd
28 is an open file descriptor referring to a terminal;
29 otherwise 0 is returned, and
30 .I errno
31 is set to indicate the error.
32 .SH ERRORS
33 .TP
34 .B EBADF
35 .I fd
36 is not a valid file descriptor.
37 .TP
38 .B ENOTTY
39 .I fd
40 refers to a file other than a terminal.
41 On some older kernels, some types of files
42 .\" e.g., FIFOs and pipes on 2.6.32
43 resulted in the error
44 .B EINVAL
45 in this case (which is a violation of POSIX, which specifies the error
46 .BR ENOTTY ).
47 .SH ATTRIBUTES
48 For an explanation of the terms used in this section, see
49 .BR attributes (7).
50 .TS
51 allbox;
52 lbx lb lb
53 l l l.
54 Interface Attribute Value
55 T{
56 .na
57 .nh
58 .BR isatty ()
59 T} Thread safety MT-Safe
60 .TE
61 .SH STANDARDS
62 POSIX.1-2008.
63 .SH HISTORY
64 POSIX.1-2001, SVr4, 4.3BSD.
65 .SH SEE ALSO
66 .BR fstat (2),
67 .BR ttyname (3)