aboutsummaryrefslogtreecommitdiffstats
path: root/community/networkmanager/musl-process-util.patch
blob: 0eb0057fd696aa8dd3faf0d2bac3539af161ae76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
--- a/shared/systemd/src/basic/process-util.c
+++ b/shared/systemd/src/basic/process-util.c
@@ -21,6 +21,9 @@
 #include <sys/wait.h>
 #include <syslog.h>
 #include <unistd.h>
+#ifndef __GLIBC__
+#include <pthread.h>
+#endif
 #if 0 /* NM_IGNORED */
 #if HAVE_VALGRIND_VALGRIND_H
 #include <valgrind/valgrind.h>
@@ -1168,11 +1171,13 @@ void reset_cached_pid(void) {
         cached_pid = CACHED_PID_UNSET;
 }
 
+#ifdef __GLIBC__
 /* We use glibc __register_atfork() + __dso_handle directly here, as they are not included in the glibc
  * headers. __register_atfork() is mostly equivalent to pthread_atfork(), but doesn't require us to link against
  * libpthread, as it is part of glibc anyway. */
 extern int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void *dso_handle);
 extern void* __dso_handle _weak_;
+#endif
 
 pid_t getpid_cached(void) {
         static bool installed = false;
@@ -1201,7 +1206,12 @@ pid_t getpid_cached(void) {
                          * only half-documented (glibc doesn't document it but LSB does — though only superficially)
                          * we'll check for errors only in the most generic fashion possible. */
 
-                        if (__register_atfork(NULL, NULL, reset_cached_pid, __dso_handle) != 0) {
+                        #ifdef __GLIBC__
+                            if (__register_atfork(NULL, NULL, reset_cached_pid, __dso_handle) != 0) {
+                        #else
+                            if (pthread_atfork(NULL, NULL, reset_cached_pid) != 0) {
+                        #endif
+
                                 /* OOM? Let's try again later */
                                 cached_pid = CACHED_PID_UNSET;
                                 return new_pid;