]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/tmpfile.3
accept.2, dup.2, eventfd.2, execve.2, fcntl.2, memfd_create.2, open.2, perf_event_ope...
[thirdparty/man-pages.git] / man3 / tmpfile.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
24.\"
25.\" References consulted:
26.\" Linux libc source code
27.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28.\" 386BSD man pages
29.\" Modified Sat Jul 24 17:46:57 1993 by Rik Faith (faith@cs.unc.edu)
30.\" Modified 2001-11-17, aeb
460495ca 31.TH TMPFILE 3 2015-08-08 "" "Linux Programmer's Manual"
fea681da
MK
32.SH NAME
33tmpfile \- create a temporary file
34.SH SYNOPSIS
35.nf
36.B #include <stdio.h>
37.sp
18a2cc04 38.B FILE *tmpfile(void);
fea681da
MK
39.fi
40.SH DESCRIPTION
60a90ecd
MK
41The
42.BR tmpfile ()
43function opens a unique temporary file
af8d55f9 44in binary read/write (w+b) mode.
fea681da 45The file will be automatically deleted when it is closed or the
af8d55f9 46program terminates.
47297adb 47.SH RETURN VALUE
60a90ecd
MK
48The
49.BR tmpfile ()
50function returns a stream descriptor, or NULL if
fea681da 51a unique filename cannot be generated or the unique file cannot be
c13182ef 52opened.
c6fa0841
MK
53In the latter case,
54.I errno
55is set to indicate the error.
fea681da 56.SH ERRORS
c13182ef 57.TP
fea681da
MK
58.B EACCES
59Search permission denied for directory in file's path prefix.
60.TP
61.B EEXIST
62Unable to generate a unique filename.
63.TP
64.B EINTR
65The call was interrupted by a signal.
66.TP
67.B EMFILE
26c32fab 68The per-process limit on the number of open file descriptors has been reached.
fea681da
MK
69.TP
70.B ENFILE
71Too many files open in the system.
72.TP
73.B ENOSPC
74There was no room in the directory to add the new filename.
75.TP
76.B EROFS
9ee4a2b6 77Read-only filesystem.
b8a15201
MS
78.SH ATTRIBUTES
79For an explanation of the terms used in this section, see
80.BR attributes (7).
81.TS
82allbox;
83lb lb lb
84l l l.
85Interface Attribute Value
86T{
87.BR tmpfile ()
88T} Thread safety MT-Safe
89.TE
47297adb 90.SH CONFORMING TO
9ac35429 91POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD, SUSv2.
fea681da 92.SH NOTES
47e9b9f1 93POSIX.1-2001 specifies:
c6fa0841
MK
94an error message may be written to
95.I stdout
96if the stream
fea681da
MK
97cannot be opened.
98.LP
d9c1ae64
MK
99The standard does not specify the directory that
100.BR tmpfile ()
c13182ef 101will use.
c6fa0841
MK
102Glibc will try the path prefix
103.I P_tmpdir
104defined
105in
106.IR <stdio.h> ,
107and if that fails the directory
108.IR /tmp .
47297adb 109.SH SEE ALSO
fea681da
MK
110.BR exit (3),
111.BR mkstemp (3),
112.BR mktemp (3),
113.BR tempnam (3),
114.BR tmpnam (3)