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 2017-09-15 "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)):
42 /* Glibc since 2.19: */ _DEFAULT_SOURCE
43 || /* Glibc versions <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
47 function clears the environment of all name-value
48 pairs and sets the value of the external variable
51 After this call, new variables can be added to the environment using
58 function returns zero on success, and a nonzero
60 .\" Most versions of UNIX return -1 on error, or do not even have errors.
61 .\" Glibc info and the Watcom C library document "a nonzero value".
63 Available since glibc 2.0.
65 For an explanation of the terms used in this section, see
71 Interface Attribute Value
74 T} Thread safety MT-Unsafe const:env
78 Various UNIX variants (DG/UX, HP-UX, QNX, ...).
79 POSIX.9 (bindings for FORTRAN77).
80 POSIX.1-1996 did not accept
84 but changed its mind and scheduled these functions for some
85 later issue of this standard (see \[sc]B.4.6.1).
94 is unavailable, the assignment
106 function may be useful in security-conscious applications that want to
107 precisely control the environment that is passed to programs
110 The application would do this by first clearing the environment
111 and then adding select environment variables.
113 Note that the main effect of
115 is to adjust the value of the pointer
117 this function does not erase the contents of the buffers
118 containing the environment definitions.
120 The DG/UX and Tru64 man pages write: If
122 has been modified by anything other than the
129 will return an error and the process environment will remain unchanged.
131 .\" HP-UX has a ENOMEM error return.