]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3p/closedir.3p
Import of man-pages 1.70
[thirdparty/man-pages.git] / man3p / closedir.3p
1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "CLOSEDIR" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
3 .\" closedir
4 .SH NAME
5 closedir \- close a directory stream
6 .SH SYNOPSIS
7 .LP
8 \fB#include <dirent.h>
9 .br
10 .sp
11 int closedir(DIR *\fP\fIdirp\fP\fB);
12 .br
13 \fP
14 .SH DESCRIPTION
15 .LP
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.
21 .SH RETURN VALUE
22 .LP
23 Upon successful completion, \fIclosedir\fP() shall return 0; otherwise,
24 -1 shall be returned and \fIerrno\fP set to indicate
25 the error.
26 .SH ERRORS
27 .LP
28 The \fIclosedir\fP() function may fail if:
29 .TP 7
30 .B EBADF
31 The \fIdirp\fP argument does not refer to an open directory stream.
32 .TP 7
33 .B EINTR
34 The \fIclosedir\fP() function was interrupted by a signal.
35 .sp
36 .LP
37 \fIThe following sections are informative.\fP
38 .SH EXAMPLES
39 .SS Closing a Directory Stream
40 .LP
41 The following program fragment demonstrates how the \fIclosedir\fP()
42 function is used.
43 .sp
44 .RS
45 .nf
46
47 \fB\&...
48 DIR *dir;
49 struct dirent *dp;
50 \&...
51 if ((dir = opendir (".")) == NULL) {
52 \&...
53 }
54 .sp
55
56 while ((dp = readdir (dir)) != NULL) {
57 \&...
58 }
59 .sp
60
61 closedir(dir);
62 \&...
63 \fP
64 .fi
65 .RE
66 .SH APPLICATION USAGE
67 .LP
68 None.
69 .SH RATIONALE
70 .LP
71 None.
72 .SH FUTURE DIRECTIONS
73 .LP
74 None.
75 .SH SEE ALSO
76 .LP
77 \fIopendir\fP() , the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
78 \fI<dirent.h>\fP
79 .SH COPYRIGHT
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 .