1CLOSEDIR(3P)               POSIX Programmer's Manual              CLOSEDIR(3P)
2
3
4

PROLOG

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

NAME

12       closedir - close a directory stream
13

SYNOPSIS

15       #include <dirent.h>
16
17       int closedir(DIR *dirp);
18
19

DESCRIPTION

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

RETURN VALUE

27       Upon  successful  completion,  closedir() shall return 0; otherwise, -1
28       shall be returned and errno set to indicate the error.
29

ERRORS

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
38       The following sections are informative.
39

EXAMPLES

41   Closing a Directory Stream
42       The following program fragment demonstrates how the closedir() function
43       is used.
44
45
46              ...
47                  DIR *dir;
48                  struct dirent *dp;
49              ...
50                  if ((dir = opendir (".")) == NULL) {
51              ...
52                  }
53
54
55                  while ((dp = readdir (dir)) != NULL) {
56              ...
57                  }
58
59
60                  closedir(dir);
61              ...
62

APPLICATION USAGE

64       None.
65

RATIONALE

67       None.
68

FUTURE DIRECTIONS

70       None.
71

SEE ALSO

73       opendir(),   the   Base  Definitions  volume  of  IEEE Std 1003.1-2001,
74       <dirent.h>
75
77       Portions of this text are reprinted and reproduced in  electronic  form
78       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
79       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
80       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
81       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
82       event of any discrepancy between this version and the original IEEE and
83       The Open Group Standard, the original IEEE and The Open Group  Standard
84       is  the  referee document. The original Standard can be obtained online
85       at http://www.opengroup.org/unix/online.html .
86
87
88
89IEEE/The Open Group                  2003                         CLOSEDIR(3P)
Impressum