为什么在手册页中 getenv MT 是安全的?

why is getenv MT-safe in man page?

在POSIX.1-2017: getenv() 函数不需要是线程安全的。

但是,在手册页中,genenv 是 MT 安全环境。

│Interface                 │ Attribute     │ Value       │
│getenv(), secure_getenv() │ Thread safety │ MT-Safe env │

然而,

The implementation of getenv() is not required to be reentrant. The string pointed to by the return value of getenv() may be statically allocated, and can be modified by a subsequent call to getenv(), putenv(3), setenv(3), or unsetenv(3).

那么,什么是 MT-safe env ??

谢谢!

我在 man 7 attributes 中得到了答案。

       env    Functions marked with env as an MT-Safety issue access the
              environment with getenv(3) or similar, without any guards to
              ensure safety in the presence of concurrent modifications.

              We do not mark these functions as MT-Unsafe, however, because
              functions that modify the environment are all marked with
              const:env and regarded as unsafe.  Being unsafe, the latter
              are not to be called when multiple threads are running or
              asynchronous signals are enabled, and so the environment can
              be considered effectively constant in these contexts, which
              makes the former safe.

谢谢shawn