blob: 4670c232a51604b762c5962f3bfa92127bff5c4f [file] [log] [blame]
Andrew Geisslerd159c7f2021-09-02 21:05:58 -05001From 1e3bc870ded807cff0d3771dd89a850d020df032 Mon Sep 17 00:00:00 2001
Brad Bishop19323692019-04-05 15:28:33 -04002From: Chen Qi <Qi.Chen@windriver.com>
3Date: Mon, 25 Feb 2019 15:03:47 +0800
William A. Kennington IIIac69b482021-06-02 12:28:27 -07004Subject: [PATCH] fix missing of __register_atfork for non-glibc builds
Brad Bishop19323692019-04-05 15:28:33 -04005
6Upstream-Status: Inappropriate [musl specific]
7
8Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
William A. Kennington IIIac69b482021-06-02 12:28:27 -07009
Brad Bishop19323692019-04-05 15:28:33 -040010---
11 src/basic/process-util.c | 7 +++++++
12 1 file changed, 7 insertions(+)
13
Andrew Geisslerd1e89492021-02-12 15:35:20 -060014diff --git a/src/basic/process-util.c b/src/basic/process-util.c
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050015index 14259ea8df..18681838ef 100644
Andrew Geisslerd1e89492021-02-12 15:35:20 -060016--- a/src/basic/process-util.c
17+++ b/src/basic/process-util.c
Andrew Geissler82c905d2020-04-13 13:39:40 -050018@@ -18,6 +18,9 @@
Brad Bishop19323692019-04-05 15:28:33 -040019 #if HAVE_VALGRIND_VALGRIND_H
20 #include <valgrind/valgrind.h>
21 #endif
22+#ifndef __GLIBC__
23+#include <pthread.h>
24+#endif
25
26 #include "alloc-util.h"
27 #include "architecture.h"
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050028@@ -1202,11 +1205,15 @@ void reset_cached_pid(void) {
Brad Bishop19323692019-04-05 15:28:33 -040029 cached_pid = CACHED_PID_UNSET;
30 }
31
32+#ifdef __GLIBC__
33 /* We use glibc __register_atfork() + __dso_handle directly here, as they are not included in the glibc
34 * headers. __register_atfork() is mostly equivalent to pthread_atfork(), but doesn't require us to link against
35 * libpthread, as it is part of glibc anyway. */
36 extern int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void *dso_handle);
37 extern void* __dso_handle _weak_;
38+#else
39+#define __register_atfork(prepare,parent,child,dso) pthread_atfork(prepare,parent,child)
40+#endif
41
42 pid_t getpid_cached(void) {
43 static bool installed = false;