chiark / gitweb /
process-util: use raw_getpid() in getpid_cache() internally (#8115)
authorLennart Poettering <lennart@poettering.net>
Wed, 7 Feb 2018 02:10:09 +0000 (03:10 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:53:59 +0000 (07:53 +0200)
We have the raw_getpid() definition in place anyway, and it's certainly
beneficial to expose the same semantics on pre glibc 2.24 and after it
too, hence always bypass glibc for this, and always cache things on our
side.

Fixes: #8113
(cherry picked from commit 996def17f99bb3f41f82032860dfcb98ff19c3ae)

src/basic/process-util.c

index 3746f224a49fb05d24682fe661d1e607a073d41f..ba8b3d80f64bc8378945368f7d35ef5c49d51d58 100644 (file)
@@ -1151,7 +1151,7 @@ pid_t getpid_cached(void) {
         case CACHED_PID_UNSET: { /* Not initialized yet, then do so now */
                 pid_t new_pid;
 
-                new_pid = getpid();
+                new_pid = raw_getpid();
 
                 if (__register_atfork(NULL, NULL, reset_cached_pid, __dso_handle) != 0) {
                         /* OOM? Let's try again later */
@@ -1164,7 +1164,7 @@ pid_t getpid_cached(void) {
         }
 
         case CACHED_PID_BUSY: /* Somebody else is currently initializing */
-                return getpid();
+                return raw_getpid();
 
         default: /* Properly initialized */
                 return current_value;