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