From: Zbigniew Jędrzejewski-Szmek Date: Tue, 7 Mar 2023 19:25:58 +0000 (+0100) Subject: man: add mention that libsystemd uses getenv() X-Git-Tag: v254-rc1~1095^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8c51e1520ba96a0d19ddecccc57899eed2634750;p=thirdparty%2Fsystemd.git 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(). --- diff --git a/man/libsystemd-pkgconfig.xml b/man/libsystemd-pkgconfig.xml index e3b0634c9f0..3d228707395 100644 --- a/man/libsystemd-pkgconfig.xml +++ b/man/libsystemd-pkgconfig.xml @@ -3,11 +3,14 @@ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> - + + Notes - These APIs are implemented as a shared - library, which can be compiled and linked to with the + Functions described here are available as a shared + library, which can be compiled against and linked to with the libsystemd pkg-config1 file. + + diff --git a/man/libudev.xml b/man/libudev.xml index c2a42cbfd46..684bd47fcdb 100644 --- a/man/libudev.xml +++ b/man/libudev.xml @@ -50,6 +50,7 @@ a udev context. + To introspect a local device on a system, a udev device object can be created via diff --git a/man/sd_bus_add_match.xml b/man/sd_bus_add_match.xml index 429a2fd412a..1ab1c0f5171 100644 --- a/man/sd_bus_add_match.xml +++ b/man/sd_bus_add_match.xml @@ -151,11 +151,7 @@ - - Notes - - - + See Also diff --git a/man/sd_listen_fds.xml b/man/sd_listen_fds.xml index 9e0be7fbf7f..e45907075c5 100644 --- a/man/sd_listen_fds.xml +++ b/man/sd_listen_fds.xml @@ -183,6 +183,7 @@ Notes + Internally, sd_listen_fds() checks whether the $LISTEN_PID environment variable diff --git a/man/sd_notify.xml b/man/sd_notify.xml index 8ef1c507cac..8a091128657 100644 --- a/man/sd_notify.xml +++ b/man/sd_notify.xml @@ -378,6 +378,7 @@ Notes + These functions send a single datagram with the state string as payload to the socket referenced in the diff --git a/man/sd_watchdog_enabled.xml b/man/sd_watchdog_enabled.xml index 1abc2f80516..b4a59f2ad10 100644 --- a/man/sd_watchdog_enabled.xml +++ b/man/sd_watchdog_enabled.xml @@ -93,6 +93,7 @@ Notes + Internally, this function parses the $WATCHDOG_PID and diff --git a/man/threads-aware.xml b/man/threads-aware.xml index fb38d07e1a8..442e45bbbba 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. +