MKSTEMP(3) | Linux Programmer's Manual | MKSTEMP(3) |
NAME
mkstemp, mkostemp, mkstemps, mkostemps - create a unique temporary fileSYNOPSIS
#include<stdlib.h>
int mkstemp(char * template );
int mkostemp(char * template , int flags );
int mkstemps(char * template , int suffixlen );
int mkostemps(char * template , int suffixlen , int flags );
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
|| /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200112L
mkostemp(): _GNU_SOURCE
mkstemps(): _BSD_SOURCE || _SVID_SOURCE
mkostemps(): _GNU_SOURCE
DESCRIPTION
The mkstemp() function generates a unique temporary filename from template, creates and opens the file, and returns an open file descriptor for the file.RETURN VALUE
On success, these functions return the file descriptor of the temporary file. On error, -1 is returned, and errno is set appropriately.ERRORS
- EEXIST
- Could not create a unique temporary filename. Now the contents of template are undefined.
- EINVAL
-
For
mkstemp() and
mkostemp(): The last six characters of
template were not XXXXXX; now
template is unchanged.
These functions may also fail with any of the errors described for open(2).
VERSIONS
mkostemp() is available since glibc 2.7. mkstemps() and mkostemps() are available since glibc 2.11.CONFORMING TO
mkstemp(): 4.3BSD, POSIX.1-2001.NOTES
In glibc versions 2.06 and earlier, the file is created with permissions 0666, that is, read and write for all users. This old behavior may be a security risk, especially since other UNIX flavors use 0600, and somebody might overlook this detail when porting programs. POSIX.1-2008 adds a requirement that the file be created with mode 0600.SEE ALSO
mkdtemp(3), mktemp(3), tempnam(3), tmpfile(3), tmpnam(3)COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.2012-12-21 | GNU |