Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame^] | 1 | From 3ca0920429f7eaf8c59f9ac8afd30a43b83d95ed Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 2 | From: Chen Qi <Qi.Chen@windriver.com> |
| 3 | Date: Mon, 25 Feb 2019 15:03:47 +0800 |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 4 | Subject: [PATCH] fix missing of __register_atfork for non-glibc builds |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 5 | |
| 6 | Upstream-Status: Inappropriate [musl specific] |
| 7 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame^] | 8 | Drop this when upgrading to 251+, systemd does not use |
| 9 | __register_atfork anymore |
| 10 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 11 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 12 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 13 | --- |
| 14 | src/basic/process-util.c | 7 +++++++ |
| 15 | 1 file changed, 7 insertions(+) |
| 16 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 17 | diff --git a/src/basic/process-util.c b/src/basic/process-util.c |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame^] | 18 | index c971852158..df6e85b1fc 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 19 | --- a/src/basic/process-util.c |
| 20 | +++ b/src/basic/process-util.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 21 | @@ -18,6 +18,9 @@ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 22 | #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 Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame^] | 31 | @@ -1161,11 +1164,15 @@ void reset_cached_pid(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 32 | 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; |