1.\" $OpenBSD: isfdtype.3,v 1.10 2019/01/25 00:19:25 millert Exp $
2.\"
3.\" Copyright (c) 2002 Todd C. Miller <millert@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.\" Sponsored in part by the Defense Advanced Research Projects
18.\" Agency (DARPA) and Air Force Research Laboratory, Air Force
19.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
20.\"
21.Dd $Mdocdate: January 25 2019 $
22.Dt ISFDTYPE 3
23.Os
24.Sh NAME
25.Nm isfdtype
26.Nd determine whether a file descriptor is of a specific type
27.Sh SYNOPSIS
28.In sys/stat.h
29.Ft int
30.Fn isfdtype "int fd" "int fdtype"
31.Sh DESCRIPTION
32The
33.Fn isfdtype
34function checks whether or not the file descriptor
35.Fa fd
36is of type
37.Fa fdtype .
38.Pp
39A list of possible file types may be found in
40.Xr stat 2
41and the
42.In sys/stat.h
43include file.
44.Sh RETURN VALUES
45The
46.Fn isfdtype
47function returns 1 if
48.Fa fd
49is of type
50.Fa fdtype
51and 0 if it is not.
52If
53.Fn isfdtype
54fails, a value of \-1 is returned and the global variable
55.Va errno
56is set to indicate the error.
57.Sh ERRORS
58The following error codes may be set in
59.Va errno :
60.Bl -tag -width Er
61.It Bq Er EBADF
62.Fa fd
63is not a valid open file descriptor.
64.It Bq Er EIO
65An I/O error occurred while reading from or writing to the file system.
66.El
67.Sh SEE ALSO
68.Xr stat 2
69.Sh HISTORY
70The
71.Fn isfdtype
72function first appeared in
73.Ox 3.3 .
74