2004-11-03 13:51:07 +00:00
|
|
|
.\" Copyright 2001 John Levon <moz@compsoc.man.ac.uk>
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
|
|
|
.\"
|
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
|
|
|
.\"
|
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
|
|
|
.\" Additions, aeb, 2001-10-17.
|
|
|
|
.TH CLEARENV 3 2001-10-17 "Linux Programmer's Manual"
|
|
|
|
.SH NAME
|
|
|
|
clearenv \- clear the environment
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
|
|
|
.B #include <stdlib.h>
|
|
|
|
.sp
|
|
|
|
.BI "int clearenv(void);"
|
|
|
|
.fi
|
|
|
|
.SH DESCRIPTION
|
2005-10-19 07:07:02 +00:00
|
|
|
The \fBclearenv\fP() function clears the environment of all name-value
|
2004-11-03 13:51:07 +00:00
|
|
|
pairs and sets the value of the external variable
|
|
|
|
.I environ
|
|
|
|
to NULL.
|
|
|
|
|
|
|
|
.SH "RETURN VALUE"
|
2005-10-19 07:07:02 +00:00
|
|
|
The \fBclearenv\fP() function returns zero on success, and a non-zero
|
2004-11-03 13:51:07 +00:00
|
|
|
value on failure.
|
|
|
|
.\" Most versions of Unix return -1 on error, or do not even have errors.
|
2005-06-15 13:32:34 +00:00
|
|
|
.\" Glibc info and the Watcom C library document "a non-zero value".
|
2004-11-03 13:51:07 +00:00
|
|
|
|
|
|
|
.SH AVAILABILITY
|
|
|
|
Not in libc4, libc5. In glibc since glibc 2.0.
|
|
|
|
|
|
|
|
.SH "CONFORMING TO"
|
2006-08-04 09:27:16 +00:00
|
|
|
Various Unix variants (DG/UX, HP-UX, QNX, ...).
|
2004-11-03 13:51:07 +00:00
|
|
|
POSIX.9 (bindings for FORTRAN77).
|
2005-10-19 07:07:02 +00:00
|
|
|
POSIX.1-1996 did not accept \fBclearenv\fP() and \fIputenv\fP(),
|
2004-11-03 13:51:07 +00:00
|
|
|
but changed its mind and scheduled these functions for some
|
2006-08-03 13:57:30 +00:00
|
|
|
later issue of this standard (cf. B.4.6.1).
|
|
|
|
However, POSIX.1-2001
|
2005-10-19 07:07:02 +00:00
|
|
|
only adds \fIputenv\fP(), and rejected \fBclearenv\fP().
|
2004-11-03 13:51:07 +00:00
|
|
|
|
|
|
|
.SH NOTES
|
|
|
|
Used in security-conscious applications. If it is unavailable
|
|
|
|
the assignment
|
|
|
|
.RS
|
|
|
|
.nf
|
|
|
|
environ = NULL;
|
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
will probably do.
|
|
|
|
.LP
|
2006-08-04 09:27:16 +00:00
|
|
|
The DG/UX and Tru64 manpages write: If
|
2004-11-03 13:51:07 +00:00
|
|
|
.I environ
|
|
|
|
has been modified by anything other than the
|
2005-11-02 11:34:24 +00:00
|
|
|
.BR putenv (),
|
|
|
|
.BR getenv (),
|
2004-11-03 13:51:07 +00:00
|
|
|
or
|
2005-11-02 11:34:24 +00:00
|
|
|
.BR clearenv ()
|
2004-11-03 13:51:07 +00:00
|
|
|
functions, then
|
2005-10-19 07:07:02 +00:00
|
|
|
.BR clearenv ()
|
2004-11-03 13:51:07 +00:00
|
|
|
will return an error and the process environment will remain unchanged.
|
|
|
|
.\" .LP
|
2006-08-03 13:57:30 +00:00
|
|
|
.\" HP-UX has a ENOMEM error return.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR getenv (3),
|
|
|
|
.BR putenv (3),
|
|
|
|
.BR setenv (3),
|
|
|
|
.BR unsetenv (3),
|
2006-04-21 00:45:46 +00:00
|
|
|
.BR environ (7)
|