Debian Codegraph @

upstream/debian-unstable/man3/mkdtemp.3

raw
1 '\" t
2 .\" Copyright 1993, David Metcalfe <[email protected]>
3 .\" Copyright 2001, John Levon <[email protected]>
4 .\" Copyright, the authors of the Linux man-pages project
5 .\"
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\"
8 .TH mkdtemp 3 2026-02-08 "Linux man-pages 6.18"
9 .SH NAME
10 mkdtemp \- create a unique temporary directory
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc ,\~ \-lc )
14 .SH SYNOPSIS
15 .nf
16 .B #include <stdlib.h>
17 .P
18 .BI "char *mkdtemp(char *" template );
19 .fi
20 .P
21 .RS -4
22 Feature Test Macro Requirements for glibc (see
23 .BR feature_test_macros (7)):
24 .RE
25 .P
26 .BR mkdtemp ():
27 .nf
28 /* Since glibc 2.19: */ _DEFAULT_SOURCE
29 || /* glibc 2.19 and earlier: */ _BSD_SOURCE
30 || /* Since glibc 2.10: */ _POSIX_C_SOURCE >= 200809L
31 .fi
32 .SH DESCRIPTION
33 The
34 .BR mkdtemp ()
35 function generates a uniquely named temporary
36 directory from
37 .IR template .
38 The last six characters of
39 .I template
40 must be XXXXXX and these are replaced with a string that makes the
41 directory name unique.
42 The directory is then created with
43 permissions 0700.
44 Since it will be modified,
45 .I template
46 must not be a string constant, but should be declared as a character array.
47 .SH RETURN VALUE
48 The
49 .BR mkdtemp ()
50 function returns a pointer to the modified template
51 string on success, and NULL on failure, in which case
52 .I errno
53 is set to indicate the error.
54 .SH ERRORS
55 .TP
56 .B EINVAL
57 The last six characters of
58 .I template
59 were not XXXXXX.
60 Now
61 .I template
62 is unchanged.
63 .P
64 Also see
65 .BR mkdir (2)
66 for other possible values for
67 .IR errno .
68 .SH ATTRIBUTES
69 For an explanation of the terms used in this section, see
70 .BR attributes (7).
71 .TS
72 allbox;
73 lbx lb lb
74 l l l.
75 Interface Attribute Value
76 T{
77 .na
78 .nh
79 .BR mkdtemp ()
80 T} Thread safety MT-Safe
81 .TE
82 .SH STANDARDS
83 POSIX.1-2008.
84 .SH HISTORY
85 glibc 2.1.91.
86 NetBSD 1.4.
87 POSIX.1-2008.
88 .SH SEE ALSO
89 .BR mktemp (1),
90 .BR mkdir (2),
91 .BR mkstemp (3),
92 .BR mktemp (3),
93 .BR tempnam (3),
94 .BR tmpfile (3),
95 .BR tmpnam (3)