]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
3 | .\" Permission is granted to make and distribute verbatim copies of this | |
4 | .\" manual provided the copyright notice and this permission notice are | |
5 | .\" preserved on all copies. | |
6 | .\" | |
7 | .\" Permission is granted to copy and distribute modified versions of this | |
8 | .\" manual under the conditions for verbatim copying, provided that the | |
9 | .\" entire resulting derived work is distributed under the terms of a | |
10 | .\" permission notice identical to this one. | |
c13182ef | 11 | .\" |
fea681da MK |
12 | .\" Since the Linux kernel and libraries are constantly changing, this |
13 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
14 | .\" responsibility for errors or omissions, or for damages resulting from | |
15 | .\" the use of the information contained herein. The author(s) may not | |
16 | .\" have taken the same level of care in the production of this manual, | |
17 | .\" which is licensed free of charge, as they might when working | |
18 | .\" professionally. | |
c13182ef | 19 | .\" |
fea681da MK |
20 | .\" Formatted or processed versions of this manual, if unaccompanied by |
21 | .\" the source, must acknowledge the copyright and authors of this work. | |
22 | .\" | |
23 | .\" References consulted: | |
24 | .\" Linux libc source code | |
25 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
26 | .\" 386BSD man pages | |
27 | .\" Modified Sat Jul 24 18:48:06 1993 by Rik Faith (faith@cs.unc.edu) | |
28 | .\" Modified Fri Jun 23 01:26:34 1995 by Andries Brouwer (aeb@cwi.nl) | |
29 | .\" (prompted by Scott Burkett <scottb@IntNet.net>) | |
30 | .\" Modified Sun Mar 28 23:44:38 1999 by Andries Brouwer (aeb@cwi.nl) | |
31 | .\" | |
32 | .TH MKTEMP 3 1993-04-03 "GNU" "Linux Programmer's Manual" | |
33 | .SH NAME | |
2c5f1089 | 34 | mktemp \- make a unique temporary filename |
fea681da MK |
35 | .SH SYNOPSIS |
36 | .nf | |
37 | .B #include <stdlib.h> | |
38 | .sp | |
39 | .BI "char *mktemp(char *" template ); | |
40 | .fi | |
41 | .SH DESCRIPTION | |
60a90ecd MK |
42 | The |
43 | .BR mktemp () | |
44 | function generates a unique temporary filename | |
1c44bd5b MK |
45 | from \fItemplate\fP. |
46 | The last six characters of \fItemplate\fP must | |
fea681da | 47 | be XXXXXX and these are replaced with a string that makes the |
c13182ef MK |
48 | filename unique. |
49 | Since it will be modified, | |
fea681da MK |
50 | .I template |
51 | must not be a string constant, but should be declared as a character array. | |
52 | .SH "RETURN VALUE" | |
60a90ecd MK |
53 | The |
54 | .BR mktemp () | |
d0eb630e MK |
55 | function always returns \fItemplate\fP. |
56 | If a unique name was created, the last six bytes of \fItemplate\fP will | |
fea681da | 57 | have been modified in such a way that the resulting name is unique |
d0eb630e MK |
58 | (i.e., does not exist already) |
59 | If a unique name could not be created, | |
60 | \fItemplate\fP is made an empty string. | |
fea681da MK |
61 | .SH ERRORS |
62 | .TP | |
63 | .B EINVAL | |
64 | The last six characters of \fItemplate\fP were not XXXXXX. | |
65 | .SH "CONFORMING TO" | |
fa5e7dd9 | 66 | 4.3BSD, POSIX.1-2001. |
19c98696 | 67 | .SH NOTES |
fea681da MK |
68 | The prototype is in |
69 | .I <unistd.h> | |
70 | for libc4, libc5, glibc1; glibc2 follows the Single Unix Specification | |
71 | and has the prototype in | |
72 | .IR <stdlib.h> . | |
73 | .SH BUGS | |
60a90ecd MK |
74 | Never use |
75 | .BR mktemp (). | |
c13182ef | 76 | Some implementations follow 4.3BSD |
357cf3fe | 77 | and replace XXXXXX by the current process ID and a single letter, |
fea681da MK |
78 | so that at most 26 different names can be returned. |
79 | Since on the one hand the names are easy to guess, and on the other | |
80 | hand there is a race between testing whether the name exists and | |
60a90ecd MK |
81 | opening the file, every use of |
82 | .BR mktemp () | |
83 | is a security risk. | |
fea681da MK |
84 | The race is avoided by |
85 | .BR mkstemp (3). | |
86 | .SH "SEE ALSO" | |
87 | .BR mkstemp (3), | |
88 | .BR tempnam (3), | |
89 | .BR tmpfile (3), | |
90 | .BR tmpnam (3) |