diff --git a/src/stdio/tmpfile.c b/src/stdio/tmpfile.c index 525090aa..34c3d487 100644 --- a/src/stdio/tmpfile.c +++ b/src/stdio/tmpfile.c @@ -1,6 +1,7 @@ #include #include #include "stdio_impl.h" +#include "pthread_impl.h" #define MAXTRIES 100 @@ -8,10 +9,23 @@ char *__randname(char *); FILE *tmpfile(void) { +#ifdef O_TMPFILE + int fd; + FILE *f = 0; + fd = sys_open("/tmp", O_RDWR|O_TMPFILE); + if (fd >= 0) { + f = __fdopen(fd, "w+"); + if (!f) __syscall(SYS_close, fd); + } + return f; +#else char s[] = "/tmp/tmpfile_XXXXXX"; + FILE *f = 0; int fd; - FILE *f; int try; + sigset_t saved_mask; + + pthread_sigmask(SIG_SETMASK, SIGALL_SET, &saved_mask); for (try=0; try