summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd/0009-fix-missing-of-__register_atfork-for-non-glibc-build.patch
blob: 24cd0897f9ac2d7518e69105a889fd360291c99d (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
41
42
43
From c6cd600f859960c6e22a7e1c8b3d9ba92021e63a Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Mon, 25 Feb 2019 15:03:47 +0800
Subject: [PATCH] fix missing of __register_atfork for non-glibc builds

Upstream-Status: Inappropriate [musl specific]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>

---
 src/basic/process-util.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/basic/process-util.c b/src/basic/process-util.c
index 14259ea8df..18681838ef 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -18,6 +18,9 @@
 #if HAVE_VALGRIND_VALGRIND_H
 #include <valgrind/valgrind.h>
 #endif
+#ifndef __GLIBC__
+#include <pthread.h>
+#endif
 
 #include "alloc-util.h"
 #include "architecture.h"
@@ -1202,11 +1205,15 @@ 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_;
+#else
+#define __register_atfork(prepare,parent,child,dso) pthread_atfork(prepare,parent,child)
+#endif
 
 pid_t getpid_cached(void) {
         static bool installed = false;