36 lines
1.4 KiB
Diff
36 lines
1.4 KiB
Diff
--- src/basic/process-util.c
|
|
+++ src/basic/process-util.c
|
|
@@ -1022,8 +1022,10 @@ static void reset_cached_pid(void) {
|
|
/* We use glibc __register_atfork() + __dso_handle directly here, as they are not included in the glibc
|
|
* headers. __register_atfork() is mostly equivalent to pthread_atfork(), but doesn't require us to link against
|
|
* libpthread, as it is part of glibc anyway. */
|
|
+#ifdef __GLIBC__
|
|
extern int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void * __dso_handle);
|
|
extern void* __dso_handle __attribute__ ((__weak__));
|
|
+#endif
|
|
|
|
pid_t getpid_cached(void) {
|
|
pid_t current_value;
|
|
--- src/shared/musl_missing.h
|
|
+++ src/shared/musl_missing.h
|
|
@@ -24,6 +24,7 @@ void elogind_set_program_name(const char* pcall);
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
+#include <pthread.h> /* for pthread_atfork */
|
|
|
|
#define strerror_r(e, m, k) (strerror_r(e, m, k) < 0 ? strdup("strerror_r() failed") : m);
|
|
|
|
@@ -99,6 +100,12 @@ typedef __compar_fn_t comparison_fn_t;
|
|
# endif
|
|
#endif // HAVE_UTMP
|
|
|
|
+/*
|
|
+ * Systemd makes use of glibc __register_atfork which is not availble on musl
|
|
+ * it is mostly equivalent to pthread_atfork, so we link against pthread
|
|
+ */
|
|
+#define __register_atfork(prepare,parent,child,dso) pthread_atfork(prepare,parent,child)
|
|
+
|
|
#endif // !defined(__GLIBC__)
|
|
|
|
#endif // ELOGIND_BASIC_MUSL_MISSING_H_INCLUDED
|