From 1b46eb23bc40206b2ed6e221dcf1d41e18df7613 Mon Sep 17 00:00:00 2001 From: Matija Skala Date: Sat, 12 Feb 2022 06:05:54 +0100 Subject: [PATCH] do not call __register_atfork directly this way it is cleaner and more portable and systemd links against libpthread anyway --- src/basic/process-util.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 0bf7448043..369edce816 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; -- 2.25.1