From 8c51e1520ba96a0d19ddecccc57899eed2634750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 7 Mar 2023 20:25:58 +0100 Subject: man: add mention that libsystemd uses getenv() See #26688: getenv() is not thread-safe, and could a possible source of problems when a multi-threaded program calls setenv()/putenv()/unsetenv() in parallel. It is not possible to avoid getenv() calls in general, since $PATH, $LANG, $SHELL, $USER, $HOME, $TZ may need to be accessed at any time. Add a warning to our docs so that people are aware of the issue. Closes #26688. (Real fixes will need to be in glibc and gnome-shell or other programs.) The text is added to threads-aware.xml to be included in various places. By including it in libsystemd-pkgconfig.xml, it is automatically added to all sd-* pages. The text is also included explicitly in pages for a few other functions which are call getenv(). --- man/threads-aware.xml | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'man/threads-aware.xml') diff --git a/man/threads-aware.xml b/man/threads-aware.xml index fb38d07e1a..442e45bbbb 100644 --- a/man/threads-aware.xml +++ b/man/threads-aware.xml @@ -12,4 +12,12 @@ from any other, even if locking is used to ensure these threads don't operate on All functions listed here are thread-safe and may be called in parallel from multiple threads. +The code described here uses +getenv3, +which is declared to be not multi-thread-safe. This means that the code calling the functions described +here must not call +setenv3 +from a parallel thread. It is recommended to only do calls to setenv() +from an early phase of the program when no other threads have been started. + -- cgit v1.2.1