1 .\" Copyright 2001 John Levon <moz@compsoc.man.ac.uk>
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Additions, aeb, 2001-10-17.
26 .TH CLEARENV 3 2021-03-22 "Linux" "Linux Programmer's Manual"
28 clearenv \- clear the environment
31 .B #include <stdlib.h>
33 .B "int clearenv(void);"
37 Feature Test Macro Requirements for glibc (see
38 .BR feature_test_macros (7)):
43 /* Glibc since 2.19: */ _DEFAULT_SOURCE
44 || /* Glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
49 function clears the environment of all name-value
50 pairs and sets the value of the external variable
53 After this call, new variables can be added to the environment using
60 function returns zero on success, and a nonzero
62 .\" Most versions of UNIX return -1 on error, or do not even have errors.
63 .\" Glibc info and the Watcom C library document "a nonzero value".
65 Available since glibc 2.0.
67 For an explanation of the terms used in this section, see
75 Interface Attribute Value
78 T} Thread safety MT-Unsafe const:env
84 Various UNIX variants (DG/UX, HP-UX, QNX, ...).
85 POSIX.9 (bindings for FORTRAN77).
86 POSIX.1-1996 did not accept
90 but changed its mind and scheduled these functions for some
91 later issue of this standard (see \[sc]B.4.6.1).
100 is unavailable, the assignment
112 function may be useful in security-conscious applications that want to
113 precisely control the environment that is passed to programs
116 The application would do this by first clearing the environment
117 and then adding select environment variables.
119 Note that the main effect of
121 is to adjust the value of the pointer
123 this function does not erase the contents of the buffers
124 containing the environment definitions.
126 The DG/UX and Tru64 man pages write: If
128 has been modified by anything other than the
135 will return an error and the process environment will remain unchanged.
137 .\" HP-UX has a ENOMEM error return.