logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

closedir.3p (2644B)


  1. '\" et
  2. .TH CLOSEDIR "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. closedir
  12. \(em close a directory stream
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <dirent.h>
  17. .P
  18. int closedir(DIR *\fIdirp\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIclosedir\fR()
  23. function shall close the directory stream referred to by the argument
  24. .IR dirp .
  25. Upon return, the value of
  26. .IR dirp
  27. may no longer point to an accessible object of the type
  28. .BR DIR .
  29. If a file descriptor is used to implement type
  30. .BR DIR ,
  31. that file descriptor shall be closed.
  32. .SH "RETURN VALUE"
  33. Upon successful completion,
  34. \fIclosedir\fR()
  35. shall return 0; otherwise, \-1 shall be returned and
  36. .IR errno
  37. set to indicate the error.
  38. .SH ERRORS
  39. The
  40. \fIclosedir\fR()
  41. function may fail if:
  42. .TP
  43. .BR EBADF
  44. The
  45. .IR dirp
  46. argument does not refer to an open directory stream.
  47. .TP
  48. .BR EINTR
  49. The
  50. \fIclosedir\fR()
  51. function was interrupted by a signal.
  52. .LP
  53. .IR "The following sections are informative."
  54. .SH EXAMPLES
  55. .SS "Closing a Directory Stream"
  56. .P
  57. The following program fragment demonstrates how the
  58. \fIclosedir\fR()
  59. function is used.
  60. .sp
  61. .RS 4
  62. .nf
  63. \&...
  64. DIR *dir;
  65. struct dirent *dp;
  66. \&...
  67. if ((dir = opendir (".")) == NULL) {
  68. \&...
  69. }
  70. .P
  71. while ((dp = readdir (dir)) != NULL) {
  72. \&...
  73. }
  74. .P
  75. closedir(dir);
  76. \&...
  77. .fi
  78. .P
  79. .RE
  80. .SH "APPLICATION USAGE"
  81. None.
  82. .SH RATIONALE
  83. None.
  84. .SH "FUTURE DIRECTIONS"
  85. None.
  86. .SH "SEE ALSO"
  87. .IR "\fIdirfd\fR\^(\|)",
  88. .IR "\fIfdopendir\fR\^(\|)"
  89. .P
  90. The Base Definitions volume of POSIX.1\(hy2017,
  91. .IR "\fB<dirent.h>\fP"
  92. .\"
  93. .SH COPYRIGHT
  94. Portions of this text are reprinted and reproduced in electronic form
  95. from IEEE Std 1003.1-2017, Standard for Information Technology
  96. -- Portable Operating System Interface (POSIX), The Open Group Base
  97. Specifications Issue 7, 2018 Edition,
  98. Copyright (C) 2018 by the Institute of
  99. Electrical and Electronics Engineers, Inc and The Open Group.
  100. In the event of any discrepancy between this version and the original IEEE and
  101. The Open Group Standard, the original IEEE and The Open Group Standard
  102. is the referee document. The original Standard can be obtained online at
  103. http://www.opengroup.org/unix/online.html .
  104. .PP
  105. Any typographical or formatting errors that appear
  106. in this page are most likely
  107. to have been introduced during the conversion of the source files to
  108. man page format. To report such errors, see
  109. https://www.kernel.org/doc/man-pages/reporting_bugs.html .