]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/tmpfile.3
All pages: Remove the 5th argument to .TH
[thirdparty/man-pages.git] / man3 / tmpfile.3
CommitLineData
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
13tmpfile \- create a temporary file
6178e88b
AC
14.SH LIBRARY
15Standard 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
24The
25.BR tmpfile ()
26function opens a unique temporary file
af8d55f9 27in binary read/write (w+b) mode.
fea681da 28The file will be automatically deleted when it is closed or the
af8d55f9 29program terminates.
47297adb 30.SH RETURN VALUE
60a90ecd
MK
31The
32.BR tmpfile ()
33function returns a stream descriptor, or NULL if
fea681da 34a unique filename cannot be generated or the unique file cannot be
c13182ef 35opened.
c6fa0841
MK
36In the latter case,
37.I errno
38is set to indicate the error.
fea681da 39.SH ERRORS
c13182ef 40.TP
fea681da
MK
41.B EACCES
42Search permission denied for directory in file's path prefix.
43.TP
44.B EEXIST
45Unable to generate a unique filename.
46.TP
47.B EINTR
bb14af39
MK
48The call was interrupted by a signal; see
49.BR signal (7).
fea681da
MK
50.TP
51.B EMFILE
26c32fab 52The per-process limit on the number of open file descriptors has been reached.
fea681da
MK
53.TP
54.B ENFILE
e258766b 55The system-wide limit on the total number of open files has been reached.
fea681da
MK
56.TP
57.B ENOSPC
58There was no room in the directory to add the new filename.
59.TP
60.B EROFS
9ee4a2b6 61Read-only filesystem.
b8a15201
MS
62.SH ATTRIBUTES
63For 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
68allbox;
c466875e 69lbx lb lb
b8a15201
MS
70l l l.
71Interface Attribute Value
72T{
73.BR tmpfile ()
74T} Thread safety MT-Safe
75.TE
c466875e
MK
76.hy
77.ad
78.sp 1
3113c7f3 79.SH STANDARDS
9ac35429 80POSIX.1-2001, POSIX.1-2008, C89, C99, SVr4, 4.3BSD, SUSv2.
fea681da 81.SH NOTES
47e9b9f1 82POSIX.1-2001 specifies:
c6fa0841
MK
83an error message may be written to
84.I stdout
85if the stream
fea681da 86cannot be opened.
dd3568a1 87.PP
d9c1ae64
MK
88The standard does not specify the directory that
89.BR tmpfile ()
c13182ef 90will use.
c6fa0841
MK
91Glibc will try the path prefix
92.I P_tmpdir
93defined
94in
95.IR <stdio.h> ,
f2a4cb65 96and 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)