Debian Codegraph @

upstream/debian-trixie/man3/isatty.3

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