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

tmpfile.3p (4185B)


  1. '\" et
  2. .TH TMPFILE "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. tmpfile
  12. \(em create a temporary file
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <stdio.h>
  17. .P
  18. FILE *tmpfile(void);
  19. .fi
  20. .SH DESCRIPTION
  21. The functionality described on this reference page is aligned with the
  22. ISO\ C standard. Any conflict between the requirements described here and the
  23. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  24. .P
  25. The
  26. \fItmpfile\fR()
  27. function shall create a temporary file and open a corresponding
  28. stream. The file shall be automatically deleted when all references
  29. to the file are closed. The file shall be opened as in
  30. \fIfopen\fR()
  31. for update (\fIwb\fP+), except that implementations may restrict the
  32. permissions, either by clearing the file mode bits or setting them
  33. to the value S_IRUSR | S_IWUSR.
  34. .P
  35. In some implementations, a permanent file may be left behind if
  36. the process calling
  37. \fItmpfile\fR()
  38. is killed while it is processing a call to
  39. \fItmpfile\fR().
  40. .P
  41. An error message may be written to standard error if the stream cannot
  42. be opened.
  43. .SH "RETURN VALUE"
  44. Upon successful completion,
  45. \fItmpfile\fR()
  46. shall return a pointer to the stream of the file that is created.
  47. Otherwise, it shall return a null pointer
  48. and set
  49. .IR errno
  50. to indicate the error.
  51. .SH ERRORS
  52. The
  53. \fItmpfile\fR()
  54. function shall fail if:
  55. .TP
  56. .BR EINTR
  57. A signal was caught during
  58. \fItmpfile\fR().
  59. .TP
  60. .BR EMFILE
  61. All file descriptors available to the process are currently open.
  62. .TP
  63. .BR EMFILE
  64. {STREAM_MAX}
  65. streams are currently open in the calling process.
  66. .TP
  67. .BR ENFILE
  68. The maximum allowable number of files is currently open in the system.
  69. .TP
  70. .BR ENOSPC
  71. The directory or file system which would contain the new file cannot be
  72. expanded.
  73. .TP
  74. .BR EOVERFLOW
  75. The file is a regular file and the size of the file cannot be
  76. represented correctly in an object of type
  77. .BR off_t .
  78. .P
  79. The
  80. \fItmpfile\fR()
  81. function may fail if:
  82. .TP
  83. .BR EMFILE
  84. {FOPEN_MAX}
  85. streams are currently open in the calling process.
  86. .TP
  87. .BR ENOMEM
  88. Insufficient storage space is available.
  89. .LP
  90. .IR "The following sections are informative."
  91. .SH EXAMPLES
  92. .SS "Creating a Temporary File"
  93. .P
  94. The following example creates a temporary file for update, and returns
  95. a pointer to a stream for the created file in the
  96. .IR fp
  97. variable.
  98. .sp
  99. .RS 4
  100. .nf
  101. #include <stdio.h>
  102. \&...
  103. FILE *fp;
  104. .P
  105. fp = tmpfile ();
  106. .fi
  107. .P
  108. .RE
  109. .SH "APPLICATION USAGE"
  110. It should be possible to open at least
  111. {TMP_MAX}
  112. temporary files during the lifetime of the program (this limit may be
  113. shared with
  114. \fItmpnam\fR())
  115. and there should be no limit on the number simultaneously open other
  116. than this limit and any limit on the number of open file descriptors
  117. or streams (\c
  118. {OPEN_MAX},
  119. {FOPEN_MAX},
  120. {STREAM_MAX}).
  121. .SH RATIONALE
  122. None.
  123. .SH "FUTURE DIRECTIONS"
  124. None.
  125. .SH "SEE ALSO"
  126. .IR "Section 2.5" ", " "Standard I/O Streams",
  127. .IR "\fIfopen\fR\^(\|)",
  128. .IR "\fImkdtemp\fR\^(\|)",
  129. .IR "\fItmpnam\fR\^(\|)",
  130. .IR "\fIunlink\fR\^(\|)"
  131. .P
  132. The Base Definitions volume of POSIX.1\(hy2017,
  133. .IR "\fB<stdio.h>\fP"
  134. .\"
  135. .SH COPYRIGHT
  136. Portions of this text are reprinted and reproduced in electronic form
  137. from IEEE Std 1003.1-2017, Standard for Information Technology
  138. -- Portable Operating System Interface (POSIX), The Open Group Base
  139. Specifications Issue 7, 2018 Edition,
  140. Copyright (C) 2018 by the Institute of
  141. Electrical and Electronics Engineers, Inc and The Open Group.
  142. In the event of any discrepancy between this version and the original IEEE and
  143. The Open Group Standard, the original IEEE and The Open Group Standard
  144. is the referee document. The original Standard can be obtained online at
  145. http://www.opengroup.org/unix/online.html .
  146. .PP
  147. Any typographical or formatting errors that appear
  148. in this page are most likely
  149. to have been introduced during the conversion of the source files to
  150. man page format. To report such errors, see
  151. https://www.kernel.org/doc/man-pages/reporting_bugs.html .