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