| 1 |
'\" t |
| 2 |
.\" Copyright 1993, David Metcalfe <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH closedir 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
closedir \- close a directory |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ,\~ \-lc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <sys/types.h> |
| 16 |
.B #include <dirent.h> |
| 17 |
.P |
| 18 |
.BI "int closedir(DIR *" dirp ); |
| 19 |
.fi |
| 20 |
.SH DESCRIPTION |
| 21 |
The |
| 22 |
.BR closedir () |
| 23 |
function closes the directory stream associated with |
| 24 |
.IR dirp . |
| 25 |
A successful call to |
| 26 |
.BR closedir () |
| 27 |
also closes the underlying file descriptor associated with |
| 28 |
.IR dirp . |
| 29 |
The directory stream descriptor |
| 30 |
.I dirp |
| 31 |
is not available |
| 32 |
after this call. |
| 33 |
.SH RETURN VALUE |
| 34 |
The |
| 35 |
.BR closedir () |
| 36 |
function returns 0 on success. |
| 37 |
On error, \-1 is returned, and |
| 38 |
.I errno |
| 39 |
is set to indicate the error. |
| 40 |
.SH ERRORS |
| 41 |
.TP |
| 42 |
.B EBADF |
| 43 |
Invalid directory stream descriptor |
| 44 |
.IR dirp . |
| 45 |
.SH ATTRIBUTES |
| 46 |
For an explanation of the terms used in this section, see |
| 47 |
.BR attributes (7). |
| 48 |
.TS |
| 49 |
allbox; |
| 50 |
lbx lb lb |
| 51 |
l l l. |
| 52 |
Interface Attribute Value |
| 53 |
T{ |
| 54 |
.na |
| 55 |
.nh |
| 56 |
.BR closedir () |
| 57 |
T} Thread safety MT-Safe |
| 58 |
.TE |
| 59 |
.SH STANDARDS |
| 60 |
POSIX.1-2008. |
| 61 |
.SH HISTORY |
| 62 |
POSIX.1-2001, SVr4, 4.3BSD. |
| 63 |
.SH SEE ALSO |
| 64 |
.BR close (2), |
| 65 |
.BR opendir (3), |
| 66 |
.BR readdir (3), |
| 67 |
.BR rewinddir (3), |
| 68 |
.BR scandir (3), |
| 69 |
.BR seekdir (3), |
| 70 |
.BR telldir (3) |