1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "CLOSEDIR" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
5 closedir \- close a directory stream
11 int closedir(DIR *\fP\fIdirp\fP\fB);
16 The \fIclosedir\fP() function shall close the directory stream referred
17 to by the argument \fIdirp\fP. Upon return, the value
18 of \fIdirp\fP may no longer point to an accessible object of the type
19 \fBDIR\fP. If a file descriptor is used to implement type
20 \fBDIR\fP, that file descriptor shall be closed.
23 Upon successful completion, \fIclosedir\fP() shall return 0; otherwise,
24 -1 shall be returned and \fIerrno\fP set to indicate
28 The \fIclosedir\fP() function may fail if:
31 The \fIdirp\fP argument does not refer to an open directory stream.
34 The \fIclosedir\fP() function was interrupted by a signal.
37 \fIThe following sections are informative.\fP
39 .SS Closing a Directory Stream
41 The following program fragment demonstrates how the \fIclosedir\fP()
51 if ((dir = opendir (".")) == NULL) {
56 while ((dp = readdir (dir)) != NULL) {
77 \fIopendir\fP() , the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
80 Portions of this text are reprinted and reproduced in electronic form
81 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
82 -- Portable Operating System Interface (POSIX), The Open Group Base
83 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
84 Electrical and Electronics Engineers, Inc and The Open Group. In the
85 event of any discrepancy between this version and the original IEEE and
86 The Open Group Standard, the original IEEE and The Open Group Standard
87 is the referee document. The original Standard can be obtained online at
88 http://www.opengroup.org/unix/online.html .