1tmpfile(3C) Standard C Library Functions tmpfile(3C)
2
3
4
6 tmpfile - create a temporary file
7
9 #include <stdio.h>
10
11 FILE *tmpfile(void);
12
13
15 The tmpfile() function creates a temporary file and opens a correspond‐
16 ing stream. The file will automatically be deleted when all references
17 to the file are closed. The file is opened as in fopen(3C) for update
18 (w+).
19
20
21 The largest value that can be represented correctly in an object of
22 type off_t will be established as the offset maximum in the open file
23 description.
24
26 Upon successful completion, tmpfile() returns a pointer to the stream
27 of the file that is created. Otherwise, it returns a null pointer and
28 sets errno to indicate the error.
29
31 The tmpfile() function will fail if:
32
33 EINTR A signal was caught during the execution of tmpfile().
34
35
36 EMFILE There are OPEN_MAX file descriptors currently open in the
37 calling process.
38
39
40 ENFILE The maximum allowable number of files is currently open in
41 the system.
42
43
44 ENOSPC The directory or file system which would contain the new file
45 cannot be expanded.
46
47
48
49 The tmpfile() function may fail if:
50
51 EMFILE There are FOPEN_MAX streams currently open in the calling
52 process.
53
54
55 ENOMEM Insufficient storage space is available.
56
57
59 The stream refers to a file which is unlinked. If the process is
60 killed in the period between file creation and unlinking, a permanent
61 file may be left behind.
62
63
64 The tmpfile() function has a transitional interface for 64-bit file
65 offsets. See lf64(5).
66
68 See attributes(5) for descriptions of the following attributes:
69
70
71
72
73 ┌─────────────────────────────┬─────────────────────────────┐
74 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
75 ├─────────────────────────────┼─────────────────────────────┤
76 │Interface Stability │Standard │
77 └─────────────────────────────┴─────────────────────────────┘
78
80 unlink(2), fopen(3C), mkstemp(3C), mktemp(3C), tmpnam(3C), lf64(5),
81 standards(5)
82
83
84
85SunOS 5.11 4 Aug 2003 tmpfile(3C)