/*
#include #include "pthread_internal.h" extern "C" pid_t __getpid(); pid_t getpid() { pthread_internal_t* self = __get_thread(); // Do we have a valid cached pid? pid_t cached_pid; if (__predict_true(self->get_cached_pid(&cached_pid))) { return cached_pid; } // We're still in the dynamic linker or we're in the middle of forking, so ask the kernel. // We don't know whether it's safe to update the cached value, so don't try. return __getpid(); } C++程xndgq/p> 48行 1.84 KB /* #include #include "pthread_internal.h" extern "C" pid_t __getpid(); pid_t getpid() { pthread_internal_t* self = __get_thread(); // Do we have a valid cached pid? pid_t cached_pid; if (__predict_true(self->get_cached_pid(&cached_pid))) { return cached_pid; } // We're still in the dynamic linker or we're in the middle of forking, so ask the kernel. // We don't know whether it's safe to update the cached value, so don't try. return __getpid(); }