]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man3/clearenv.3
Removed trailing white space at end of lines
[thirdparty/man-pages.git] / man3 / clearenv.3
index 101fdeff198d6ec48ebe2395e3ff0b9d51478d58..9ae0519598f9fe28a7e354d6d018b5fdaf2ff707 100644 (file)
 .\" %%%LICENSE_END
 .\"
 .\" Additions, aeb, 2001-10-17.
-.TH CLEARENV 3  2014-08-19 "Linux" "Linux Programmer's Manual"
+.TH CLEARENV 3  2017-09-15 "Linux" "Linux Programmer's Manual"
 .SH NAME
 clearenv \- clear the environment
 .SH SYNOPSIS
 .nf
 .B #include <stdlib.h>
-.sp
+.PP
 .B "int clearenv(void);"
 .fi
-.sp
+.PP
 .in -4n
 Feature Test Macro Requirements for glibc (see
 .BR feature_test_macros (7)):
 .in
-.sp
+.PP
 .BR clearenv ():
-_SVID_SOURCE || _BSD_SOURCE
+    /* Glibc since 2.19: */ _DEFAULT_SOURCE
+        || /* Glibc versions <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
 .SH DESCRIPTION
 The
 .BR clearenv ()
@@ -47,6 +48,10 @@ function clears the environment of all name-value
 pairs and sets the value of the external variable
 .I environ
 to NULL.
+After this call, new variables can be added to the environment using
+.BR putenv (3)
+and
+.BR setenv (3).
 .SH RETURN VALUE
 The
 .BR clearenv ()
@@ -68,7 +73,7 @@ T{
 .BR clearenv ()
 T}     Thread safety   MT-Unsafe const:env
 .TE
-
+.sp 1
 .SH CONFORMING TO
 Various UNIX variants (DG/UX, HP-UX, QNX, ...).
 POSIX.9 (bindings for FORTRAN77).
@@ -77,23 +82,41 @@ POSIX.1-1996 did not accept
 and
 .BR putenv (3),
 but changed its mind and scheduled these functions for some
-later issue of this standard (cf. B.4.6.1).
+later issue of this standard (see \[sc]B.4.6.1).
 However, POSIX.1-2001
 adds only
 .BR putenv (3),
 and rejected
 .BR clearenv ().
 .SH NOTES
-Used in security-conscious applications.
-If it is unavailable
-the assignment
-.nf
-
-    environ = NULL;
-
-.fi
+On systems where
+.BR clearenv ()
+is unavailable, the assignment
+.PP
+.in +4n
+.EX
+environ = NULL;
+.EE
+.in
+.PP
 will probably do.
-.LP
+.PP
+The
+.BR clearenv ()
+function may be useful in security-conscious applications that want to
+precisely control the environment that is passed to programs
+executed using
+.BR exec (3).
+The application would do this by first clearing the environment
+and then adding select environment variables.
+.PP
+Note that the main effect of
+.BR clearenv ()
+is to adjust the value of the pointer
+.BR environ (7);
+this function does not erase the contents of the buffers
+containing the environment definitions.
+.PP
 The DG/UX and Tru64 man pages write: If
 .I environ
 has been modified by anything other than the