OSDN Git Service

9e372e7e7bddae0280177f507af4010afdb1a3f0
[linuxjm/LDP_man-pages.git] / original / man3 / clearenv.3
1 .\" Copyright 2001 John Levon <moz@compsoc.man.ac.uk>
2 .\"
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.
7 .\"
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.
12 .\"
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
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Additions, aeb, 2001-10-17.
26 .TH CLEARENV 3  2010-10-04 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 clearenv \- clear the environment
29 .SH SYNOPSIS
30 .nf
31 .B #include <stdlib.h>
32 .sp
33 .B "int clearenv(void);"
34 .fi
35 .sp
36 .in -4n
37 Feature Test Macro Requirements for glibc (see
38 .BR feature_test_macros (7)):
39 .in
40 .sp
41 .BR clearenv ():
42 _SVID_SOURCE || _BSD_SOURCE
43 .SH DESCRIPTION
44 The
45 .BR clearenv ()
46 function clears the environment of all name-value
47 pairs and sets the value of the external variable
48 .I environ
49 to NULL.
50 .SH RETURN VALUE
51 The
52 .BR clearenv ()
53 function returns zero on success, and a nonzero
54 value on failure.
55 .\" Most versions of UNIX return -1 on error, or do not even have errors.
56 .\" Glibc info and the Watcom C library document "a nonzero value".
57 .SH VERSIONS
58 Not in libc4, libc5.
59 In glibc since glibc 2.0.
60 .SH CONFORMING TO
61 Various UNIX variants (DG/UX, HP-UX, QNX, ...).
62 POSIX.9 (bindings for FORTRAN77).
63 POSIX.1-1996 did not accept
64 .BR clearenv ()
65 and
66 .BR putenv (3),
67 but changed its mind and scheduled these functions for some
68 later issue of this standard (cf. B.4.6.1).
69 However, POSIX.1-2001
70 adds only
71 .BR putenv (3),
72 and rejected
73 .BR clearenv ().
74 .SH NOTES
75 Used in security-conscious applications.
76 If it is unavailable
77 the assignment
78 .nf
79
80     environ = NULL;
81
82 .fi
83 will probably do.
84 .LP
85 The DG/UX and Tru64 man pages write: If
86 .I environ
87 has been modified by anything other than the
88 .BR putenv (3),
89 .BR getenv (3),
90 or
91 .BR clearenv ()
92 functions, then
93 .BR clearenv ()
94 will return an error and the process environment will remain unchanged.
95 .\" .LP
96 .\" HP-UX has a ENOMEM error return.
97 .SH SEE ALSO
98 .BR getenv (3),
99 .BR putenv (3),
100 .BR setenv (3),
101 .BR unsetenv (3),
102 .BR environ (7)
103 .SH COLOPHON
104 This page is part of release 3.67 of the Linux
105 .I man-pages
106 project.
107 A description of the project,
108 information about reporting bugs,
109 and the latest version of this page,
110 can be found at
111 \%http://www.kernel.org/doc/man\-pages/.