OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / tmpfile.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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.
12 .\"
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.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
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
31 .TH TMPFILE 3  2008-07-14 "" "Linux Programmer's Manual"
32 .SH NAME
33 tmpfile \- create a temporary file
34 .SH SYNOPSIS
35 .nf
36 .B #include <stdio.h>
37 .sp
38 .B FILE *tmpfile(void);
39 .fi
40 .SH DESCRIPTION
41 The
42 .BR tmpfile ()
43 function opens a unique temporary file
44 in binary read/write (w+b) mode.
45 The file will be automatically deleted when it is closed or the
46 program terminates.
47 .SH RETURN VALUE
48 The
49 .BR tmpfile ()
50 function returns a stream descriptor, or NULL if
51 a unique filename cannot be generated or the unique file cannot be
52 opened.
53 In the latter case,
54 .I errno
55 is set to indicate the error.
56 .SH ERRORS
57 .TP
58 .B EACCES
59 Search permission denied for directory in file's path prefix.
60 .TP
61 .B EEXIST
62 Unable to generate a unique filename.
63 .TP
64 .B EINTR
65 The call was interrupted by a signal.
66 .TP
67 .B EMFILE
68 Too many file descriptors in use by the process.
69 .TP
70 .B ENFILE
71 Too many files open in the system.
72 .TP
73 .B ENOSPC
74 There was no room in the directory to add the new filename.
75 .TP
76 .B EROFS
77 Read-only filesystem.
78 .SH CONFORMING TO
79 SVr4, 4.3BSD, C89, C99, SUSv2, POSIX.1-2001.
80 .SH NOTES
81 POSIX.1-2001 specifies:
82 an error message may be written to
83 .I stdout
84 if the stream
85 cannot be opened.
86 .LP
87 The standard does not specify the directory that
88 .BR tmpfile ()
89 will use.
90 Glibc will try the path prefix
91 .I P_tmpdir
92 defined
93 in
94 .IR <stdio.h> ,
95 and if that fails the directory
96 .IR /tmp .
97 .SH SEE ALSO
98 .BR exit (3),
99 .BR mkstemp (3),
100 .BR mktemp (3),
101 .BR tempnam (3),
102 .BR tmpnam (3)
103 .SH COLOPHON
104 This page is part of release 3.79 of the Linux
105 .I man-pages
106 project.
107 A description of the project,
108 information about reporting bugs,
109 and the latest version of this page,
110 can be found at
111 \%http://www.kernel.org/doc/man\-pages/.