1TMPNAM(3P)                 POSIX Programmer's Manual                TMPNAM(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       tmpnam — create a name for a temporary file
14

SYNOPSIS

16       #include <stdio.h>
17
18       char *tmpnam(char *s);
19

DESCRIPTION

21       The functionality described on this reference page is aligned with  the
22       ISO C  standard.  Any  conflict between the requirements described here
23       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2008
24       defers to the ISO C standard.
25
26       The  tmpnam() function shall generate a string that is a valid pathname
27       that does not name an existing file. The function is potentially  capa‐
28       ble  of  generating {TMP_MAX} different strings, but any or all of them
29       may already be in use by existing files and thus not be suitable return
30       values.
31
32       The  tmpnam()  function  generates  a  different string each time it is
33       called from the same process, up to {TMP_MAX} times. If  it  is  called
34       more than {TMP_MAX} times, the behavior is implementation-defined.
35
36       The  implementation shall behave as if no function defined in this vol‐
37       ume of POSIX.1‐2008, except tempnam(), calls tmpnam().
38
39       The tmpnam() function need not be thread-safe if  called  with  a  NULL
40       parameter.
41

RETURN VALUE

43       Upon  successful  completion,  tmpnam()  shall  return  a  pointer to a
44       string. If no suitable string can be generated, the  tmpnam()  function
45       shall return a null pointer.
46
47       If the argument s is a null pointer, tmpnam() shall leave its result in
48       an internal static object and return a pointer to that  object.  Subse‐
49       quent  calls  to tmpnam() may modify the same object. If the argument s
50       is not a null pointer, it is presumed to point to an array of at  least
51       L_tmpnam chars; tmpnam() shall write its result in that array and shall
52       return the argument as its value.
53

ERRORS

55       No errors are defined.
56
57       The following sections are informative.
58

EXAMPLES

60   Generating a Pathname
61       The following example generates a unique pathname and stores it in  the
62       array pointed to by ptr.
63
64           #include <stdio.h>
65           ...
66           char pathname[L_tmpnam+1];
67           char *ptr;
68
69           ptr = tmpnam(pathname);
70

APPLICATION USAGE

72       This function only creates pathnames. It is the application's responsi‐
73       bility to create and remove the files.
74
75       Between the time a pathname is created and the file is  opened,  it  is
76       possible  for  some  other process to create a file with the same name.
77       Applications may find tmpfile() more useful.
78
79       Applications should use the tmpfile(), mkstemp(),  or  mkdtemp()  func‐
80       tions instead of the obsolescent tmpnam() function.
81

RATIONALE

83       None.
84

FUTURE DIRECTIONS

86       The tmpnam() function may be removed in a future version.
87

SEE ALSO

89       fopen(), open(), mkdtemp(), tempnam(), tmpfile(), unlink()
90
91       The Base Definitions volume of POSIX.1‐2008, <stdio.h>
92
94       Portions  of  this text are reprinted and reproduced in electronic form
95       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
96       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
97       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
98       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
99       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
100       event of any discrepancy between this version and the original IEEE and
101       The Open Group Standard, the original IEEE and The Open Group  Standard
102       is  the  referee document. The original Standard can be obtained online
103       at http://www.unix.org/online.html .
104
105       Any typographical or formatting errors that appear  in  this  page  are
106       most likely to have been introduced during the conversion of the source
107       files to man page format. To report such errors,  see  https://www.ker
108       nel.org/doc/man-pages/reporting_bugs.html .
109
110
111
112IEEE/The Open Group                  2013                           TMPNAM(3P)
Impressum