Re: clearing the environment

Jorge Almeida <[email protected]> Sun, 3 Jun 2012 07:55:50 +0100
Newsgroups gmane.linux.lib.dietlibc
Message-ID <CAKpSnpLtfyiQ1HCLi1p9Bf8wt-mebmxAWm1R0v+Vtz-D8a1QQA@mail.gmail.com>
On Sun, Jun 3, 2012 at 5:27 AM, Felix von Leitner
<[email protected]> wrote:
>> What would be the proper way of clearing the environment before setting some
>> variable and then execve()'ing?
>
> execve takes the new environment as an argument.
> The proper way is to pass a pointer to an empty environment to execve.
>
> Note there is a difference between NULL and a pointer to NULL. :)
>
So, if I understood right, we shouldn't use clearenv() or equivalent and then
setup a few variables, but rather build from scratch an array an pass it to
execve. Is there some issue with clearenv, e.g. related with memory leaking?

Thanks

Jorge