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