]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
5fbde956 | 3 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da MK |
4 | .\" |
5 | .\" References consulted: | |
6 | .\" Linux libc source code | |
7 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
8 | .\" 386BSD man pages | |
9 | .\" Modified Sat Jul 24 17:46:57 1993 by Rik Faith (faith@cs.unc.edu) | |
10 | .\" Modified 2001-11-17, aeb | |
45186a5d | 11 | .TH TMPFILE 3 2021-03-22 "Linux man-pages (unreleased)" |
fea681da MK |
12 | .SH NAME |
13 | tmpfile \- create a temporary file | |
6178e88b AC |
14 | .SH LIBRARY |
15 | Standard C library | |
8fc3b2cf | 16 | .RI ( libc ", " \-lc ) |
fea681da MK |
17 | .SH SYNOPSIS |
18 | .nf | |
19 | .B #include <stdio.h> | |
68e4db0a | 20 | .PP |
18a2cc04 | 21 | .B FILE *tmpfile(void); |
fea681da MK |
22 | .fi |
23 | .SH DESCRIPTION | |
60a90ecd MK |
24 | The |
25 | .BR tmpfile () | |
26 | function opens a unique temporary file | |
af8d55f9 | 27 | in binary read/write (w+b) mode. |
fea681da | 28 | The file will be automatically deleted when it is closed or the |
af8d55f9 | 29 | program terminates. |
47297adb | 30 | .SH RETURN VALUE |
60a90ecd MK |
31 | The |
32 | .BR tmpfile () | |
33 | function returns a stream descriptor, or NULL if | |
fea681da | 34 | a unique filename cannot be generated or the unique file cannot be |
c13182ef | 35 | opened. |
c6fa0841 MK |
36 | In the latter case, |
37 | .I errno | |
38 | is set to indicate the error. | |
fea681da | 39 | .SH ERRORS |
c13182ef | 40 | .TP |
fea681da MK |
41 | .B EACCES |
42 | Search permission denied for directory in file's path prefix. | |
43 | .TP | |
44 | .B EEXIST | |
45 | Unable to generate a unique filename. | |
46 | .TP | |
47 | .B EINTR | |
bb14af39 MK |
48 | The call was interrupted by a signal; see |
49 | .BR signal (7). | |
fea681da MK |
50 | .TP |
51 | .B EMFILE | |
26c32fab | 52 | The per-process limit on the number of open file descriptors has been reached. |
fea681da MK |
53 | .TP |
54 | .B ENFILE | |
e258766b | 55 | The system-wide limit on the total number of open files has been reached. |
fea681da MK |
56 | .TP |
57 | .B ENOSPC | |
58 | There was no room in the directory to add the new filename. | |
59 | .TP | |
60 | .B EROFS | |
9ee4a2b6 | 61 | Read-only filesystem. |
b8a15201 MS |
62 | .SH ATTRIBUTES |
63 | For an explanation of the terms used in this section, see | |
64 | .BR attributes (7). | |
c466875e MK |
65 | .ad l |
66 | .nh | |
b8a15201 MS |
67 | .TS |
68 | allbox; | |
c466875e | 69 | lbx lb lb |
b8a15201 MS |
70 | l l l. |
71 | Interface Attribute Value | |
72 | T{ | |
73 | .BR tmpfile () | |
74 | T} Thread safety MT-Safe | |
75 | .TE | |
c466875e MK |
76 | .hy |
77 | .ad | |
78 | .sp 1 | |
3113c7f3 | 79 | .SH STANDARDS |
9ac35429 | 80 | POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD, SUSv2. |
fea681da | 81 | .SH NOTES |
47e9b9f1 | 82 | POSIX.1-2001 specifies: |
c6fa0841 MK |
83 | an error message may be written to |
84 | .I stdout | |
85 | if the stream | |
fea681da | 86 | cannot be opened. |
dd3568a1 | 87 | .PP |
d9c1ae64 MK |
88 | The standard does not specify the directory that |
89 | .BR tmpfile () | |
c13182ef | 90 | will use. |
c6fa0841 MK |
91 | Glibc will try the path prefix |
92 | .I P_tmpdir | |
93 | defined | |
94 | in | |
95 | .IR <stdio.h> , | |
f2a4cb65 | 96 | and if that fails, then the directory |
c6fa0841 | 97 | .IR /tmp . |
47297adb | 98 | .SH SEE ALSO |
fea681da MK |
99 | .BR exit (3), |
100 | .BR mkstemp (3), | |
101 | .BR mktemp (3), | |
102 | .BR tempnam (3), | |
103 | .BR tmpnam (3) |