| 1 |
.\" Copyright 2014, Michael Kerrisk <[email protected]> |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 5 |
.\" |
| 6 |
.TH isfdtype 3 2026-02-08 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
isfdtype \- test file type of a file descriptor |
| 9 |
.SH LIBRARY |
| 10 |
Standard C library |
| 11 |
.RI ( libc ,\~ \-lc ) |
| 12 |
.SH SYNOPSIS |
| 13 |
.nf |
| 14 |
.B #include <sys/stat.h> |
| 15 |
.B #include <sys/socket.h> |
| 16 |
.P |
| 17 |
.BI "int isfdtype(int " fd ", int " fdtype ); |
| 18 |
.fi |
| 19 |
.P |
| 20 |
.RS -4 |
| 21 |
Feature Test Macro Requirements for glibc (see |
| 22 |
.BR feature_test_macros (7)): |
| 23 |
.RE |
| 24 |
.P |
| 25 |
.BR isfdtype (): |
| 26 |
.nf |
| 27 |
Since glibc 2.20: |
| 28 |
_DEFAULT_SOURCE |
| 29 |
Before glibc 2.20: |
| 30 |
_BSD_SOURCE || _SVID_SOURCE |
| 31 |
.fi |
| 32 |
.SH DESCRIPTION |
| 33 |
The |
| 34 |
.BR isfdtype () |
| 35 |
function tests whether the file descriptor |
| 36 |
.I fd |
| 37 |
refers to a file of type |
| 38 |
.IR fdtype . |
| 39 |
The |
| 40 |
.I fdtype |
| 41 |
argument specifies one of the |
| 42 |
.B S_IF* |
| 43 |
constants defined in |
| 44 |
.I <sys/stat.h> |
| 45 |
and documented in |
| 46 |
.BR stat (2) |
| 47 |
(e.g., |
| 48 |
.BR S_IFREG ). |
| 49 |
.SH RETURN VALUE |
| 50 |
The |
| 51 |
.BR isfdtype () |
| 52 |
function returns 1 if the file descriptor |
| 53 |
.I fd |
| 54 |
is of type |
| 55 |
.I fdtype |
| 56 |
and 0 if it is not. |
| 57 |
On failure, \-1 is returned and |
| 58 |
.I errno |
| 59 |
is set to indicate the error. |
| 60 |
.SH ERRORS |
| 61 |
The |
| 62 |
.BR isfdtype () |
| 63 |
function can fail with any of the same errors as |
| 64 |
.BR fstat (2). |
| 65 |
.SH VERSIONS |
| 66 |
Portable applications should use |
| 67 |
.BR fstat (2) |
| 68 |
instead. |
| 69 |
.SH STANDARDS |
| 70 |
None. |
| 71 |
.SH HISTORY |
| 72 |
It appeared in the draft POSIX.1g standard. |
| 73 |
It is present on OpenBSD and Tru64 UNIX |
| 74 |
(where the required header file in both cases is just |
| 75 |
.IR <sys/stat.h> , |
| 76 |
as shown in the POSIX.1g draft). |
| 77 |
.SH SEE ALSO |
| 78 |
.BR fstat (2) |