aboutsummaryrefslogtreecommitdiff
path: root/man/man3/opentemp.3
blob: 6177b44acc2f0d17ec96146fd01d62394b0744a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
.TH OPENTEMP 3
.SH NAME
opentemp \- create a uniquely-named file
.SH SYNOPSIS
.B #include <u.h>
.br
.B #include <libc.h>
.PP
.B
int opentemp(char *template)
.SH DESCRIPTION
.I Opentemp
replaces
.I template
by a unique file name, and returns the
address of the template.
The template should look like a file name with eleven trailing
.LR X s.
The
.LR X s
are replaced by a letter followed by the current process id.
Letters from
.L a
to
.L z
are tried until the name of a file that does not yet exist
(see
.IR access (2))
is generated.
.I Opentemp
then creates the file for reading and writing
and returns the file descriptor.
.PP
If no such name can be generated,
.I opentemp
returns \-1.
.PP
.I Opentemp
avoids races.
Two simultaneous calls to
.I opentemp
will never return the same name.
.SH SOURCE
.B \*9/src/lib9/opentemp.c
.SH "SEE ALSO
.I create
in
.IR open (3)