1 .\" Copyright 2001 John Levon <moz@compsoc.man.ac.uk>
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" Additions, aeb, 2001-10-17.
6 .TH CLEARENV 3 2021-03-22 "Linux man-pages (unreleased)" "Linux Programmer's Manual"
8 clearenv \- clear the environment
11 .RI ( libc ", " \-lc )
14 .B #include <stdlib.h>
16 .B "int clearenv(void);"
20 Feature Test Macro Requirements for glibc (see
21 .BR feature_test_macros (7)):
26 /* Glibc since 2.19: */ _DEFAULT_SOURCE
27 || /* Glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
32 function clears the environment of all name-value
33 pairs and sets the value of the external variable
36 After this call, new variables can be added to the environment using
43 function returns zero on success, and a nonzero
45 .\" Most versions of UNIX return -1 on error, or do not even have errors.
46 .\" Glibc info and the Watcom C library document "a nonzero value".
48 Available since glibc 2.0.
50 For an explanation of the terms used in this section, see
58 Interface Attribute Value
61 T} Thread safety MT-Unsafe const:env
67 Various UNIX variants (DG/UX, HP-UX, QNX, ...).
68 POSIX.9 (bindings for FORTRAN77).
69 POSIX.1-1996 did not accept
73 but changed its mind and scheduled these functions for some
74 later issue of this standard (see \[sc]B.4.6.1).
83 is unavailable, the assignment
95 function may be useful in security-conscious applications that want to
96 precisely control the environment that is passed to programs
99 The application would do this by first clearing the environment
100 and then adding select environment variables.
102 Note that the main effect of
104 is to adjust the value of the pointer
106 this function does not erase the contents of the buffers
107 containing the environment definitions.
109 The DG/UX and Tru64 man pages write: If
111 has been modified by anything other than the
118 will return an error and the process environment will remain unchanged.
120 .\" HP-UX has a ENOMEM error return.