tempnam(3) Library Functions Manual tempnam(3) tempnam - C (libc, -lc) #include char *tempnam(const char *dir, const char *pfx); glibc (. feature_test_macros(7)): tempnam(): glibc 2.19: _DEFAULT_SOURCE glibc 2.19 : _BSD_SOURCE || _SVID_SOURCE . mkstemp(3) tmpfile(3). tempnam() , tempnam() . pfx ( , pfx -- NULL- ). , , , <<>> ( , , ). : (1) TMPDIR, , . (2) , dir NULL , . (3) P_tmpdir ( ), . (4) , , , . , tempnam(), malloc(3) free(3). On success, the tempnam() function returns a pointer to a unique temporary filename. It returns NULL if a unique name cannot be generated, with errno set to indicate the error. ENOMEM . attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |tempnam() | | MT-Safe env | +----------------------------+----------------------------------------------------------+--------------------------+ POSIX.1-2008. SVr4, 4.3BSD, POSIX.1-2001. Obsoleted in POSIX.1-2008. tempnam() , , , , , tempnam() , open(2) , . , open(2) O_EXCL. -- mkstemp(3) tmpfile(3). SUSv2 does not mention the use of TMPDIR; glibc will use it only when the program is not set-user-ID. On SVr4, the directory used under (4) is /tmp (and this is what glibc does). tempnam() , , , ( tmpnam(3)). tempnam() , TMP_MAX ( ). TMP_MAX , . tempnam() pfx. tempnam() glibc EEXIST, . <<>> . , . mkstemp(3), mktemp(3), tmpfile(3), tmpnam(3) () Azamat Hackimov , Dmitry Bolkhovskikh , Yuri Kozlov , Kirill Rekhov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.15 17 2025 . tempnam(3)