Blob


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