1CLOSEDIR(3P) POSIX Programmer's Manual CLOSEDIR(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 closedir — close a directory stream
14
16 #include <dirent.h>
17
18 int closedir(DIR *dirp);
19
21 The closedir() function shall close the directory stream referred to by
22 the argument dirp. Upon return, the value of dirp may no longer point
23 to an accessible object of the type DIR. If a file descriptor is used
24 to implement type DIR, that file descriptor shall be closed.
25
27 Upon successful completion, closedir() shall return 0; otherwise, −1
28 shall be returned and errno set to indicate the error.
29
31 The closedir() function may fail if:
32
33 EBADF The dirp argument does not refer to an open directory stream.
34
35 EINTR The closedir() function was interrupted by a signal.
36
37 The following sections are informative.
38
40 Closing a Directory Stream
41 The following program fragment demonstrates how the closedir() function
42 is used.
43
44 ...
45 DIR *dir;
46 struct dirent *dp;
47 ...
48 if ((dir = opendir (".")) == NULL) {
49 ...
50 }
51
52 while ((dp = readdir (dir)) != NULL) {
53 ...
54 }
55
56 closedir(dir);
57 ...
58
60 None.
61
63 None.
64
66 None.
67
69 dirfd(), fdopendir()
70
71 The Base Definitions volume of POSIX.1‐2008, <dirent.h>
72
74 Portions of this text are reprinted and reproduced in electronic form
75 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
76 -- Portable Operating System Interface (POSIX), The Open Group Base
77 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
78 cal and Electronics Engineers, Inc and The Open Group. (This is
79 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
80 event of any discrepancy between this version and the original IEEE and
81 The Open Group Standard, the original IEEE and The Open Group Standard
82 is the referee document. The original Standard can be obtained online
83 at http://www.unix.org/online.html .
84
85 Any typographical or formatting errors that appear in this page are
86 most likely to have been introduced during the conversion of the source
87 files to man page format. To report such errors, see https://www.ker‐
88 nel.org/doc/man-pages/reporting_bugs.html .
89
90
91
92IEEE/The Open Group 2013 CLOSEDIR(3P)