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

NAME

12       tmpnam — create a name for a temporary file
13

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

59   Generating a Pathname
60       The following example generates a unique pathname and stores it in  the
61       array pointed to by ptr.
62
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‐2017, <stdio.h>
92
94       Portions  of  this text are reprinted and reproduced in electronic form
95       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
96       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
97       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
98       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
99       event of any discrepancy between this version and the original IEEE and
100       The  Open Group Standard, the original IEEE and The Open Group Standard
101       is the referee document. The original Standard can be  obtained  online
102       at http://www.opengroup.org/unix/online.html .
103
104       Any  typographical  or  formatting  errors that appear in this page are
105       most likely to have been introduced during the conversion of the source
106       files  to  man page format. To report such errors, see https://www.ker
107       nel.org/doc/man-pages/reporting_bugs.html .
108
109
110
111IEEE/The Open Group                  2017                           TMPNAM(3P)
Impressum