William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1 | From bb41fe773881a8f1d9615d388320b9c6fc47bfe5 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 | |
| 8 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 9 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 10 | --- |
| 11 | src/basic/process-util.c | 7 +++++++ |
| 12 | 1 file changed, 7 insertions(+) |
| 13 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 14 | diff --git a/src/basic/process-util.c b/src/basic/process-util.c |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 15 | index 7d4301eadb..caa9dfe3a3 100644 |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 16 | --- a/src/basic/process-util.c |
| 17 | +++ b/src/basic/process-util.c |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 18 | @@ -18,6 +18,9 @@ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 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" |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 28 | @@ -1121,11 +1124,15 @@ void reset_cached_pid(void) { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 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; |