pthread: assign handle argument before resuming the created thread

It's not specified by POSIX:
http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_create.html
"There is no requirement on the implementation that the ID of the
created thread be available before the newly created thread starts executing."

However I've run into it with MPD which assumed this, probably because
of Linux:
https://github.com/MusicPlayerDaemon/MPD/issues/188

It doesn't hurt anyway.
This commit is contained in:
François Revol 2018-01-06 05:07:43 +01:00
parent da30fdf96a
commit 4069b740e5

View File

@ -160,8 +160,8 @@ pthread_create(pthread_t* _thread, const pthread_attr_t* attr,
}
__set_stack_protection();
resume_thread(thread->id);
*_thread = thread;
resume_thread(thread->id);
return 0;
}