1CLOSEDIR(P) POSIX Programmer's Manual CLOSEDIR(P)
2
3
4
6 closedir - close a directory stream
7
9 #include <dirent.h>
10
11 int closedir(DIR *dirp);
12
13
15 The closedir() function shall close the directory stream referred to by
16 the argument dirp. Upon return, the value of dirp may no longer point
17 to an accessible object of the type DIR. If a file descriptor is used
18 to implement type DIR, that file descriptor shall be closed.
19
21 Upon successful completion, closedir() shall return 0; otherwise, -1
22 shall be returned and errno set to indicate the error.
23
25 The closedir() function may fail if:
26
27 EBADF The dirp argument does not refer to an open directory stream.
28
29 EINTR The closedir() function was interrupted by a signal.
30
31
32 The following sections are informative.
33
35 Closing a Directory Stream
36 The following program fragment demonstrates how the closedir() function
37 is used.
38
39
40 ...
41 DIR *dir;
42 struct dirent *dp;
43 ...
44 if ((dir = opendir (".")) == NULL) {
45 ...
46 }
47
48
49 while ((dp = readdir (dir)) != NULL) {
50 ...
51 }
52
53
54 closedir(dir);
55 ...
56
58 None.
59
61 None.
62
64 None.
65
67 opendir() , the Base Definitions volume of IEEE Std 1003.1-2001,
68 <dirent.h>
69
71 Portions of this text are reprinted and reproduced in electronic form
72 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
73 -- Portable Operating System Interface (POSIX), The Open Group Base
74 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
75 Electrical and Electronics Engineers, Inc and The Open Group. In the
76 event of any discrepancy between this version and the original IEEE and
77 The Open Group Standard, the original IEEE and The Open Group Standard
78 is the referee document. The original Standard can be obtained online
79 at http://www.opengroup.org/unix/online.html .
80
81
82
83IEEE/The Open Group 2003 CLOSEDIR(P)