blob: e7b7269f95d9203d4515939e9b35a0cae0024e8c [file] [log] [blame]
Andrew Geisslerd5838332022-05-27 11:33:10 -05001From 3ca0920429f7eaf8c59f9ac8afd30a43b83d95ed 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
Andrew Geisslerd5838332022-05-27 11:33:10 -05008Drop this when upgrading to 251+, systemd does not use
9__register_atfork anymore
10
Brad Bishop19323692019-04-05 15:28:33 -040011Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
William A. Kennington IIIac69b482021-06-02 12:28:27 -070012
Brad Bishop19323692019-04-05 15:28:33 -040013---
14 src/basic/process-util.c | 7 +++++++
15 1 file changed, 7 insertions(+)
16
Andrew Geisslerd1e89492021-02-12 15:35:20 -060017diff --git a/src/basic/process-util.c b/src/basic/process-util.c
Andrew Geisslerd5838332022-05-27 11:33:10 -050018index c971852158..df6e85b1fc 100644
Andrew Geisslerd1e89492021-02-12 15:35:20 -060019--- a/src/basic/process-util.c
20+++ b/src/basic/process-util.c
Andrew Geissler82c905d2020-04-13 13:39:40 -050021@@ -18,6 +18,9 @@
Brad Bishop19323692019-04-05 15:28:33 -040022 #if HAVE_VALGRIND_VALGRIND_H
23 #include <valgrind/valgrind.h>
24 #endif
25+#ifndef __GLIBC__
26+#include <pthread.h>
27+#endif
28
29 #include "alloc-util.h"
30 #include "architecture.h"
Andrew Geisslerd5838332022-05-27 11:33:10 -050031@@ -1161,11 +1164,15 @@ void reset_cached_pid(void) {
Brad Bishop19323692019-04-05 15:28:33 -040032 cached_pid = CACHED_PID_UNSET;
33 }
34
35+#ifdef __GLIBC__
36 /* We use glibc __register_atfork() + __dso_handle directly here, as they are not included in the glibc
37 * headers. __register_atfork() is mostly equivalent to pthread_atfork(), but doesn't require us to link against
38 * libpthread, as it is part of glibc anyway. */
39 extern int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void *dso_handle);
40 extern void* __dso_handle _weak_;
41+#else
42+#define __register_atfork(prepare,parent,child,dso) pthread_atfork(prepare,parent,child)
43+#endif
44
45 pid_t getpid_cached(void) {
46 static bool installed = false;