projects
/
musl
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
c8569948d7ff14d4c996f32fb132fb9c0cd371fc
[musl]
/
src
/
stdio
/
tmpfile.c
1
#include <stdio.h>
2
#include <fcntl.h>
3
#include "stdio_impl.h"
4
5
#define MAXTRIES 100
6
7
char *__randname(char *);
8
9
FILE *tmpfile(void)
10
{
11
char s[] = "/tmp/tmpfile_XXXXXX";
12
int fd;
13
FILE *f;
14
int try;
15
for (try=0; try<MAXTRIES; try++) {
16
__randname(s+13);
17
fd = sys_open(s, O_RDWR|O_CREAT|O_EXCL, 0600);
18
if (fd >= 0) {
19
f = __fdopen(fd, "w+");
20
__syscall(SYS_unlink, s);
21
return f;
22
}
23
}
24
return 0;
25
}
26
27
LFS64(tmpfile);