1 .\" Copyright (c) 1999 Andries Brouwer (aeb@cwi.nl)
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" 2003-11-15, aeb, added tmpnam_r
7 .TH tmpnam 3 (date) "Linux man-pages (unreleased)"
9 tmpnam, tmpnam_r \- create a name for a temporary file
12 .RI ( libc ", " \-lc )
17 .BI "char *tmpnam(char *" s );
18 .BI "char *tmpnam_r(char *" s );
22 Feature Test Macro Requirements for glibc (see
23 .BR feature_test_macros (7)):
30 Up to and including glibc 2.19:
31 _BSD_SOURCE || _SVID_SOURCE
35 avoid using these functions; use
43 function returns a pointer to a string that is a valid filename,
44 and such that a file with this name did not exist at some point
45 in time, so that naive programmers may think it
46 a suitable name for a temporary file.
49 is NULL, this name is generated in an internal static buffer
50 and may be overwritten by the next call to
54 is not NULL, the name is copied to the character array (of length
61 is returned in case of success.
63 The created pathname has a directory prefix
77 function performs the same task as
79 but returns NULL (to indicate an error) if
83 These functions return a pointer to a unique temporary
84 filename, or NULL if a unique name cannot be generated.
86 No errors are defined.
88 For an explanation of the terms used in this section, see
96 Interface Attribute Value
99 T} Thread safety MT-Unsafe race:tmpnam/!s
102 T} Thread safety MT-Safe
109 SVr4, 4.3BSD, C89, C99, POSIX.1-2001.
115 is a nonstandard extension that is also available
116 .\" Appears to be on Solaris
117 on a few other systems.
121 function generates a different string each time it is called,
125 If it is called more than
128 the behavior is implementation defined.
130 Although these functions generate names that are difficult to guess,
131 it is nevertheless possible that between the time that
132 the pathname is returned and the time that the program opens it,
133 another program might create that pathname using
135 or create it as a symbolic link.
136 This can lead to security holes.
137 To avoid such possibilities, use the
140 flag to open the pathname.
146 Portable applications that use threads cannot call
148 with a NULL argument if either
151 .B _POSIX_THREAD_SAFE_FUNCTIONS
154 Never use these functions.