#include <stdlib.h> int clearenv(void);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
clearenv():
/* Glibc since 2.19: */ _DEFAULT_SOURCE
|| /* Glibc versions <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
インターフェース | 属性 | 値 |
clearenv() | Thread safety | MT-Unsafe const:env |
environ = NULL;
というように変数 environ を設定すればよい。
The clearenv() function may be useful in security-conscious applications that want to precisely control the environment that is passed to programs executed using exec(3). The application would do this by first clearing the environment and then adding select environment variables.
Note that the main effect of clearenv() is to adjust the value of the pointer environ(7); this function does not erase the contents of the buffers containing the environment definitions.
DG/UX と Tru64 man ページには次のように記されている: environ が putenv(3), getenv(3), clearenv() 関数以外で変更された場合、 clearenv() はエラーを返し、プロセス環境は変更前のままにされる。
[man1]
[man2]
[man3]
[man4]
[man5]
[man6]
[man7]
[man8]
[a]
[b]
[c]
[d]
[e]
[f]
[g]
[h]
[i]
[j]
[k]
[l]
[m]
[n]
[o]
[p]
[q]
[r]
[s]
[t]
[u]
[v]
[w]
[x]
[y]
[z]