From: Matija Skala Date: Sat, 12 Feb 2022 05:05:54 +0000 (+0100) Subject: do not call __register_atfork directly X-Git-Tag: v251-rc1~302 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1b46eb23bc40206b2ed6e221dcf1d41e18df7613;p=thirdparty%2Fsystemd.git do not call __register_atfork directly this way it is cleaner and more portable and systemd links against libpthread anyway --- diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 0bf7448043c..369edce816b 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -1161,12 +1162,6 @@ void reset_cached_pid(void) { cached_pid = CACHED_PID_UNSET; } -/* 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 _weak_; - pid_t getpid_cached(void) { static bool installed = false; pid_t current_value; @@ -1194,7 +1189,7 @@ pid_t getpid_cached(void) { * only half-documented (glibc doesn't document it but LSB does — though only superficially) * we'll check for errors only in the most generic fashion possible. */ - if (__register_atfork(NULL, NULL, reset_cached_pid, __dso_handle) != 0) { + if (pthread_atfork(NULL, NULL, reset_cached_pid) != 0) { /* OOM? Let's try again later */ cached_pid = CACHED_PID_UNSET; return new_pid;