projects
/
oweals
/
musl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
fix non-atomicity of puts
[oweals/musl.git]
/
src
/
stdio
/
tmpfile.c
1
#include <stdio.h>
2
#include <fcntl.h>
3
#include <unistd.h>
4
#include "stdio_impl.h"
5
6
FILE *tmpfile(void)
7
{
8
char buf[L_tmpnam], *s;
9
int fd;
10
FILE *f;
11
for (;;) {
12
s = tmpnam(buf);
13
if (!s) return NULL;
14
fd = syscall(SYS_open, s, O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600);
15
if (fd >= 0) {
16
f = __fdopen(fd, "w+");
17
remove(s);
18
return f;
19
}
20
}
21
}
22
23
LFS64(tmpfile);