1tmpfile(3) Library Functions Manual tmpfile(3)
2
3
4
6 tmpfile - create a temporary file
7
9 Standard C library (libc, -lc)
10
12 #include <stdio.h>
13
14 FILE *tmpfile(void);
15
17 The tmpfile() function opens a unique temporary file in binary
18 read/write (w+b) mode. The file will be automatically deleted when it
19 is closed or the program terminates.
20
22 The tmpfile() function returns a stream descriptor, or NULL if a unique
23 filename cannot be generated or the unique file cannot be opened. In
24 the latter case, errno is set to indicate the error.
25
27 EACCES Search permission denied for directory in file's path prefix.
28
29 EEXIST Unable to generate a unique filename.
30
31 EINTR The call was interrupted by a signal; see signal(7).
32
33 EMFILE The per-process limit on the number of open file descriptors has
34 been reached.
35
36 ENFILE The system-wide limit on the total number of open files has been
37 reached.
38
39 ENOSPC There was no room in the directory to add the new filename.
40
41 EROFS Read-only filesystem.
42
44 For an explanation of the terms used in this section, see at‐
45 tributes(7).
46
47 ┌────────────────────────────────────────────┬───────────────┬─────────┐
48 │Interface │ Attribute │ Value │
49 ├────────────────────────────────────────────┼───────────────┼─────────┤
50 │tmpfile() │ Thread safety │ MT-Safe │
51 └────────────────────────────────────────────┴───────────────┴─────────┘
52
54 The standard does not specify the directory that tmpfile() will use.
55 glibc will try the path prefix P_tmpdir defined in <stdio.h>, and if
56 that fails, then the directory /tmp.
57
59 C11, POSIX.1-2008.
60
62 POSIX.1-2001, C89, SVr4, 4.3BSD, SUSv2.
63
65 POSIX.1-2001 specifies: an error message may be written to stdout if
66 the stream cannot be opened.
67
69 exit(3), mkstemp(3), mktemp(3), tempnam(3), tmpnam(3)
70
71
72
73Linux man-pages 6.05 2023-07-20 tmpfile(3)