version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
MKSTEMP |
|
|
2 |
!!!MKSTEMP |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
ERRORS |
|
|
8 |
BUGS |
|
|
9 |
CONFORMING TO |
|
|
10 |
NOTE |
|
|
11 |
SEE ALSO |
|
|
12 |
---- |
|
|
13 |
!!NAME |
|
|
14 |
|
|
|
15 |
|
|
|
16 |
mkstemp - create a unique temporary file |
|
|
17 |
!!SYNOPSIS |
|
|
18 |
|
|
|
19 |
|
|
|
20 |
__#include |
|
|
21 |
__''template''__); |
|
|
22 |
__ |
|
|
23 |
!!DESCRIPTION |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
The __mkstemp()__ function generates a unique temporary |
|
|
27 |
file name from ''template''. The last six characters of |
|
|
28 |
''template'' must be XXXXXX and these are replaced with a |
|
|
29 |
string that makes the filename unique. The file is then |
|
|
30 |
created with mode read/write and permissions 0666 (glibc |
|
|
31 |
2.0.6 and earlier), 0600 (glibc 2.0.7 and later). Since it |
|
|
32 |
will be modified, ''template'' must not be a string |
|
|
33 |
constant, but should be declared as a character array. The |
|
|
34 |
file is opened with the O_EXCL flag, guaranteeing that when |
|
|
35 |
__mkstemp__ returns successfully we are the only |
|
|
36 |
user. |
|
|
37 |
!!RETURN VALUE |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
The __mkstemp()__ function returns the file descriptor fd |
|
|
41 |
of the temporary file or -1 on error. |
|
|
42 |
!!ERRORS |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
__EINVAL__ |
|
|
46 |
|
|
|
47 |
|
|
|
48 |
The last six characters of ''template'' were not XXXXXX. |
|
|
49 |
Now ''template'' is unchanged. |
|
|
50 |
|
|
|
51 |
|
|
|
52 |
__EEXIST__ |
|
|
53 |
|
|
|
54 |
|
|
|
55 |
Could not create a unique temporary filename. Now the |
|
|
56 |
contents of ''template'' are undefined. |
|
|
57 |
!!BUGS |
|
|
58 |
|
|
|
59 |
|
|
|
60 |
The old behaviour (creating a file with mode 0666) may be a |
|
|
61 |
security risk, especially since other Unix flavours use |
|
|
62 |
0600, and somebody might overlook this detail when porting |
|
|
63 |
programs. |
|
|
64 |
|
|
|
65 |
|
|
|
66 |
Don't use this function, use tmpfile(3) instead. It's |
|
|
67 |
better defined and more portable. |
|
|
68 |
!!CONFORMING TO |
|
|
69 |
|
|
|
70 |
|
|
|
71 |
BSD 4.3, SUSv2 |
|
|
72 |
!!NOTE |
|
|
73 |
|
|
|
74 |
|
|
|
75 |
The prototype is in '''' for libc4, |
|
|
76 |
libc5, glibc1; glibc2 follows the Single Unix Specification |
|
|
77 |
and has the prototype in |
|
|
78 |
''''. |
|
|
79 |
!!SEE ALSO |
|
|
80 |
|
|
|
81 |
|
|
|
82 |
mktemp(3), tmpnam(3), tempnam(3), |
|
|
83 |
tmpfile(3) |
|
|
84 |
---- |