X-Git-Url: https://pd.if.org/git/?p=pdclib.old;a=blobdiff_plain;f=platform%2Fposix%2Ffunctions%2Fstdio%2Ftmpfile.c;fp=platform%2Fposix%2Ffunctions%2Fstdio%2Ftmpfile.c;h=ad7aa7e78de86073deb0e0854e15372372696ed2;hp=deb992ccbc80e2133e6eb1a102823ba838c06784;hb=3862b03514c94f37966f61693619e6483ead6045;hpb=35d48051496adf237dcd22ff1324e93b6f351284 diff --git a/platform/posix/functions/stdio/tmpfile.c b/platform/posix/functions/stdio/tmpfile.c index deb992c..ad7aa7e 100644 --- a/platform/posix/functions/stdio/tmpfile.c +++ b/platform/posix/functions/stdio/tmpfile.c @@ -13,13 +13,15 @@ #include #include #include - #include <_PDCLIB_glue.h> - -#include -#include -#include #include +#ifdef __linux__ +/* get O_CLOEXEC without sys/types.h being awful */ +#include +int open(const char *fname, int flags, ...); +#else +#include +#endif extern const _PDCLIB_fileops_t _PDCLIB_fileops; @@ -52,7 +54,7 @@ FILE* _PDCLIB_nothrow tmpfile( void ) (file might exist but not readable). Replace with something more appropriate. */ - fd = open( filename, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR ); + fd = open( filename, O_CREAT | O_EXCL | O_RDWR, 0600 ); if ( fd != -1 ) { break; @@ -61,9 +63,9 @@ FILE* _PDCLIB_nothrow tmpfile( void ) close( urandom ); FILE* rc = _PDCLIB_fvopen(((_PDCLIB_fd_t){ .sval = fd}), &_PDCLIB_fileops, - _PDCLIB_FWRITE | _PDCLIB_FRW | + _PDCLIB_FWRITE | _PDCLIB_FRW | _PDCLIB_DELONCLOSE, filename); - if( rc == NULL ) + if( rc == NULL ) { close( fd ); return NULL;