2 ms·
It’s easy to sterilize your code in this regard (although as this article points out you need to know to do it). POSIX implements a three-argument `main` funct
by gumby 3y ago
It’s easy to sterilize your code in this regard (although as this article points out you need to know to do it).
POSIX implements a three-argument `main` function (just look at `exec()`) where the third argument is `char* envp[]`. You can call `setenv` to manipulate it.
But easiest is to just null out the POSIX extern `char* environ` (save a copy if you want to consult it yourself later). Just `man 7 environ`
- naruhodo 3y agoIt's not clear from the man pages, but `setenv()` mutates `environ`. In particular, setting a previously-undefined variable causes `environ` to be reallocated. Whereas `setenv()` of an extant variable changes just that value in the current `environ` pointer array.
- garaetjjte 3y ago>But easiest is to just null out the POSIX And then wonder why some shared library dependency few layers deep blew up.