tzfile.5, tzselect.8: sync from tzdb upstream
[man-pages.git] / man3 / tmpfile.3
blobf238ec7e3451a20181b79711dd7fe0de2621137c
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 .PP
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 .ad l
67 .nh
68 .TS
69 allbox;
70 lbx lb lb
71 l l l.
72 Interface       Attribute       Value
74 .BR tmpfile ()
75 T}      Thread safety   MT-Safe
76 .TE
77 .hy
78 .ad
79 .sp 1
80 .SH STANDARDS
81 POSIX.1-2001, POSIX.1-2008, C99, SVr4, 4.3BSD, SUSv2.
82 .SH NOTES
83 POSIX.1-2001 specifies:
84 an error message may be written to
85 .I stdout
86 if the stream
87 cannot be opened.
88 .PP
89 The standard does not specify the directory that
90 .BR tmpfile ()
91 will use.
92 glibc will try the path prefix
93 .I P_tmpdir
94 defined
96 .IR <stdio.h> ,
97 and if that fails, then the directory
98 .IR /tmp .
99 .SH SEE ALSO
100 .BR exit (3),
101 .BR mkstemp (3),
102 .BR mktemp (3),
103 .BR tempnam (3),
104 .BR tmpnam (3)