2 .\" Copyright (c) 1999 Andries Brouwer (aeb@cwi.nl)
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" 2003-11-15, aeb, added tmpnam_r
8 .TH tmpnam 3 (date) "Linux man-pages (unreleased)"
10 tmpnam, tmpnam_r \- create a name for a temporary file
13 .RI ( libc ", " \-lc )
18 .BI "[[deprecated]] char *tmpnam(char *" s );
19 .BI "[[deprecated]] char *tmpnam_r(char *" s );
23 Feature Test Macro Requirements for glibc (see
24 .BR feature_test_macros (7)):
31 Up to and including glibc 2.19:
32 _BSD_SOURCE || _SVID_SOURCE
36 avoid using these functions; use
44 function returns a pointer to a string that is a valid filename,
45 and such that a file with this name did not exist at some point
46 in time, so that naive programmers may think it
47 a suitable name for a temporary file.
50 is NULL, this name is generated in an internal static buffer
51 and may be overwritten by the next call to
55 is not NULL, the name is copied to the character array (of length
62 is returned in case of success.
64 The created pathname has a directory prefix
78 function performs the same task as
80 but returns NULL (to indicate an error) if
84 These functions return a pointer to a unique temporary
85 filename, or NULL if a unique name cannot be generated.
87 No errors are defined.
89 For an explanation of the terms used in this section, see
95 Interface Attribute Value
100 T} Thread safety MT-Unsafe race:tmpnam/!s
105 T} Thread safety MT-Safe
118 SVr4, 4.3BSD, C89, POSIX.1-2001.
119 Obsolete in POSIX.1-2008.
126 function generates a different string each time it is called,
130 If it is called more than
133 the behavior is implementation defined.
135 Although these functions generate names that are difficult to guess,
136 it is nevertheless possible that between the time that
137 the pathname is returned and the time that the program opens it,
138 another program might create that pathname using
140 or create it as a symbolic link.
141 This can lead to security holes.
142 To avoid such possibilities, use the
145 flag to open the pathname.
151 Portable applications that use threads cannot call
153 with a NULL argument if either
156 .B _POSIX_THREAD_SAFE_FUNCTIONS
159 Never use these functions.