Make getpid work before the main thread is initialized.
Bug: http://b/29622562 Test: code dependent on this change no longer crashes Change-Id: I40936f7b35d9e58182aeb2e34e52f54088700825
This commit is contained in:
parent
250667aaf6
commit
3e45901439
|
@ -35,10 +35,12 @@ extern "C" pid_t __getpid();
|
||||||
pid_t getpid() {
|
pid_t getpid() {
|
||||||
pthread_internal_t* self = __get_thread();
|
pthread_internal_t* self = __get_thread();
|
||||||
|
|
||||||
// Do we have a valid cached pid?
|
if (__predict_true(self)) {
|
||||||
pid_t cached_pid;
|
// Do we have a valid cached pid?
|
||||||
if (__predict_true(self->get_cached_pid(&cached_pid))) {
|
pid_t cached_pid;
|
||||||
return 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're still in the dynamic linker or we're in the middle of forking, so ask the kernel.
|
||||||
|
|
Loading…
Reference in New Issue