blob: 0fc320420ee956dbc9d7bb8fc5a96fb6f95a7aaa [file] [log] [blame]
Andrew Geissler595f6302022-01-24 19:11:47 +00001From c7453b716ae308b89cf4b2b231a36ddd38a49752 Mon Sep 17 00:00:00 2001
2From: Chen Qi <Qi.Chen@windriver.com>
3Date: Mon, 25 Feb 2019 15:03:47 +0800
4Subject: [PATCH] fix missing of __register_atfork for non-glibc builds
5
6Upstream-Status: Inappropriate [musl specific]
7
8Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
9
10---
11 src/basic/process-util.c | 7 +++++++
12 1 file changed, 7 insertions(+)
13
14diff --git a/src/basic/process-util.c b/src/basic/process-util.c
15index 461bbfe9a5..2d06f9f60a 100644
16--- a/src/basic/process-util.c
17+++ b/src/basic/process-util.c
18@@ -18,6 +18,9 @@
19 #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"
28@@ -1202,11 +1205,15 @@ void reset_cached_pid(void) {
29 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;