close_range.2: Glibc 2.34 has added a close_range() wrapper
[man-pages.git] / man3 / isfdtype.3
blob22f000d1cc1383cbff39ffb4f3b39f998ad711d5
1 .\" Copyright (C) 2014 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH ISFDTYPE 3 2021-03-22 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 isfdtype \- test file type of a file descriptor
28 .SH SYNOPSIS
29 .nf
30 .B #include <sys/stat.h>
31 .B #include <sys/socket.h>
32 .PP
33 .BI "int isfdtype(int " fd ", int " fdtype );
34 .fi
35 .PP
36 .RS -4
37 Feature Test Macro Requirements for glibc (see
38 .BR feature_test_macros (7)):
39 .RE
40 .PP
41 .BR isfdtype ():
42 .nf
43     Since glibc 2.20:
44         _DEFAULT_SOURCE
45     Before glibc 2.20:
46         _BSD_SOURCE || _SVID_SOURCE
47 .fi
48 .SH DESCRIPTION
49 The
50 .BR isfdtype ()
51 function tests whether the file descriptor
52 .I fd
53 refers to a file of type
54 .IR fdtype .
55 The
56 .I fdtype
57 argument specifies one of the
58 .B S_IF*
59 constants defined in
60 .I <sys/stat.h>
61 and documented in
62 .BR stat (2)
63 (e.g.,
64 .BR S_IFREG ).
65 .SH RETURN VALUE
66 The
67 .BR isfdtype ()
68 function returns 1 if the file descriptor
69 .I fd
70 is of type
71 .IR fdtype
72 and 0 if it is not.
73 On failure, \-1 is returned and
74 .I errno
75 is set to indicate the error.
76 .SH ERRORS
77 The
78 .BR isfdtype ()
79 function can fail with any of the same errors as
80 .BR fstat (2).
81 .SH CONFORMING TO
82 The
83 .BR isfdtype ()
84 function is not specified in any standard,
85 but did appear in the draft POSIX.1g standard.
86 It is present on OpenBSD and Tru64 UNIX
87 (where the required header file in both cases is just
88 .IR <sys/stat.h> ,
89 as shown in the POSIX.1g draft),
90 and possibly other systems.
91 .SH NOTES
92 Portable applications should use
93 .BR fstat (2)
94 instead.
95 .SH SEE ALSO
96 .BR fstat (2)