mkdtemp(3)
okay bestie, welcome to the mkdtemp(3) page from the Library Functions Manual β it's literally about making a unique temporary directory, and yes, it's iconic. π
β¨ NAME β¨
mkdtempβ create a unique temporary directory π
π LIBRARY π
Standard C library (libc, -lc) β that's where she lives, no cap. π
πΈ SYNOPSIS πΈ
#include <stdlib.h>
char *mkdtemp(char *template);
π§ Feature Test Macro Requirements for glibc (see feature_test_macros(7)) π§
for mkdtemp(), the feature test macros are giving:
mkdtemp():
/* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc 2.19 and earlier: */ _BSD_SOURCE
|| /* Since glibc 2.10: */ _POSIX_C_SOURCE >= 200809L
π DESCRIPTION π
The mkdtemp() function generates a uniquely named temporary directory from template. The last six characters of template must be XXXXXX β like literally those six X's β and those get replaced with a string that makes the directory name unique. Then the directory is created with permissions 0700. And because it's gonna be modified, template must not be a string constant, bestie; it should be declared as a character array. π«Ά
π RETURN VALUE π
On success, mkdtemp() returns a pointer to the modified template string. On failure, it returns NULL, and when that happens errno is set to indicate the error. success is slay, failure is π.
π ERRORS π
EINVALβ the last six characters oftemplatewere notXXXXXX. Nowtemplateis unchanged. π
Also see mkdir(2) for other possible values for errno.
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7).
- Interface:
mkdtemp() - Attribute: Thread safety
- Value:
MT-Safe
β STANDARDS β
POSIX.1-2008. periodt. π
π¦ HISTORY π¦
glibc 2.1.91. NetBSD 1.4. POSIX.1-2008. the heritage, the range. π¦
π SEE ALSO π
xoxo, Linux man-pages 6.20 β dated 2026-02-08 β page mkdtemp(3) πβ¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- Copyright 2001, John Levon <moz@compsoc.man.ac.uk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms