libroot: set __main_thread_id in libroot initialize_before instead of entry point
DT_INIT, DT_INIT_ARRAY, initialize_before, initialize_after are called before executable entry point so __main_thread_id may be uninitalized there. It cause getpid() to return zero if called in one of image initalizers before main(). Fixes #11797. Change-Id: Ia745db9ffeaeb6de4dd46b868b1575d0780b54d9 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5254 Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
parent
b3dab377a9
commit
b2059b9f15
@ -62,7 +62,7 @@ initialize_before(image_id imageID)
|
||||
}
|
||||
|
||||
__libc_argc = __gRuntimeLoader->program_args->arg_count;
|
||||
__libc_argv = __gRuntimeLoader->program_args->args;
|
||||
__libc_argv = argv_save = __gRuntimeLoader->program_args->args;
|
||||
|
||||
__gRuntimeLoader->call_atexit_hooks_for_range
|
||||
= _call_atexit_hooks_for_range;
|
||||
@ -70,7 +70,7 @@ initialize_before(image_id imageID)
|
||||
if (__gRuntimeLoader->program_args->umask != (mode_t)-1)
|
||||
umask(__gRuntimeLoader->program_args->umask);
|
||||
|
||||
pthread_self()->id = find_thread(NULL);
|
||||
__main_thread_id = pthread_self()->id = find_thread(NULL);
|
||||
|
||||
get_system_info(&info);
|
||||
__gCPUCount = info.cpu_count;
|
||||
|
Loading…
x
Reference in New Issue
Block a user