]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
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)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 7 Feb 2018 02:10:09 +0000 (11:10 +0900)
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
src/basic/process-util.c

index dc7c9ef9ef686a58052c8c9027a235096febd765..e04bcc97827cb7bf53f6039ed518274d7825153f 100644 (file)
@@ -1137,7 +1137,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 */
@@ -1150,7 +1150,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;