Main index | Section 3 | Options |
#include <stdlib.h>
#include <unistd.h>
The mkstemp() function makes the same replacement to the template and creates the template file, mode 0600, returning a file descriptor opened for reading and writing. This avoids the race between testing for a file's existence and opening it for use.
The mkostemp() function is like mkstemp() but allows specifying additional open(2) flags (defined in <fcntl.h>). The permitted flags are O_APPEND, O_DIRECT, O_SHLOCK, O_EXLOCK, O_SYNC and O_CLOEXEC.
The mkstemps() and mkostemps() functions act the same as mkstemp() and mkostemp() respectively, except they permit a suffix to exist in the template. The template should be of the form /tmp/tmpXXXXXXsuffix. The mkstemps() and mkostemps() function are told the length of the suffix string.
The mkostempsat() function acts the same as mkostemps() but takes an additional directory descriptor as a parameter. The temporary file is created relative to the corresponding directory, or to the current working directory if the special value AT_FDCWD is specified. If the template path is an absolute path, the dfd parameter is ignored and the behavior is identical to mkostemps().
The mkdtemp() function makes the same replacement to the template as in mktemp() and creates the template directory, mode 0700.
[ENOTDIR] | |
The pathname portion of the template is not an existing directory. | |
The mkostemp() and mkostemps() functions may also set errno to the following value:
[EINVAL] | |
The oflags argument is invalid. | |
The mkstemp(), mkostemp(), mkstemps(), mkostemps() and mkdtemp() functions may also set errno to any value specified by the stat(2) function.
The mkstemp(), mkostemp(), mkstemps() and mkostemps() functions may also set errno to any value specified by the open(2) function.
The mkdtemp() function may also set errno to any value specified by the mkdir(2) function.
The mkdtemp(), mkstemp() and mktemp() function prototypes are also available from <unistd.h>.
MKTEMP (3) | July 29, 2019 |
Main index | Section 3 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | A typical Unix /bin or /usr/bin directory contains a hundred different kinds of programs, written by dozens of egotistical programmers, each with its own syntax, operating paradigm, rules of use ... strategies for specifying options, and different sets of constraints. | ” |
— The Unix Haters' handbook |