1 .\" Copyright (c) 1999 Andries Brouwer (aeb@cwi.nl)
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.
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.
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
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" 2003-11-15, aeb, added tmpnam_r
27 .TH TMPNAM 3 2014-02-27 "" "Linux Programmer's Manual"
29 tmpnam, tmpnam_r \- create a name for a temporary file
34 .BI "char *tmpnam(char *" s );
48 function returns a pointer to a string that is a valid filename,
49 and such that a file with this name did not exist at some point
50 in time, so that naive programmers may think it
51 a suitable name for a temporary file.
54 is NULL, this name is generated in an internal static buffer
55 and may be overwritten by the next call to
59 is not NULL, the name is copied to the character array (of length
66 is returned in case of success.
68 The pathname that is created, has a directory prefix
82 function returns a pointer to a unique temporary
83 filename, or NULL if a unique name cannot be generated.
85 No errors are defined.
87 .SS Multithreading (see pthreads(7))
90 function is thread-safe with exceptions.
91 It is not thread-safe if called with a NULL parameter.
95 function is thread-safe.
97 SVr4, 4.3BSD, C89, C99, POSIX.1-2001.
104 function generates a different string each time it is called,
108 If it is called more than
111 the behavior is implementation defined.
115 generates names that are difficult to guess,
116 it is nevertheless possible that between the time that
118 returns a pathname, and the time that the program opens it,
119 another program might create that pathname using
121 or create it as a symbolic link.
122 This can lead to security holes.
123 To avoid such possibilities, use the
126 flag to open the pathname.
132 Portable applications that use threads cannot call
134 with a NULL argument if either
137 .B _POSIX_THREAD_SAFE_FUNCTIONS
140 A POSIX draft proposed to use a function
149 return s ? tmpnam(s) : NULL;
154 apparently as a warning not to use NULL.
155 A few systems implement it.
156 To get a glibc prototype for this function from
166 Never use this function.
178 This page is part of release 3.78 of the Linux
181 A description of the project,
182 information about reporting bugs,
183 and the latest version of this page,
185 \%http://www.kernel.org/doc/man\-pages/.