--- src/systemd/src/basic/process-util.c.orig 2018-03-20 23:12:35.698715891 +0100 +++ src/systemd/src/basic/process-util.c 2018-03-20 23:17:24.114733986 +0100 @@ -36,6 +36,9 @@ #include #include #include +#ifndef __GLIBC__ +#include +#endif #if 0 /* NM_IGNORED */ #if HAVE_VALGRIND_VALGRIND_H #include @@ -1015,11 +1018,13 @@ static void reset_cached_pid(void) { cached_pid = CACHED_PID_UNSET; } +#ifdef __GLIBC__ /* 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. */ 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; @@ -1042,7 +1047,11 @@ pid_t getpid_cached(void) { new_pid = getpid(); +#ifdef __GLIBC__ if (__register_atfork(NULL, NULL, reset_cached_pid, __dso_handle) != 0) { +#else + if (pthread_atfork(NULL, NULL, reset_cached_pid) != 0) { +#endif /* OOM? Let's try again later */ cached_pid = CACHED_PID_UNSET; return new_pid;