Signature pthread_create(3):
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine) (void *), void *arg);
What are the requirements for argument storage duration pthread_t *thread? The man page for pthread_createsays:
Before returning, a successful call pthread_create()stores the identifier of the new thread in the buffer pointed to thread;
But it is unclear whether this means that it stores the value there so that the caller can check it, or if he uses this buffer to store the value (assuming that the buffer must remain usable throughout the child’s life cycle).
Similarly, it pthread_selfsays it returns
the same value that is returned in *threadthe call pthread_create(3)that created this thread.
, , , *thread, , , *thread.
, , - :
void make_thread(void) {
pthread_t tid;
return pthread_create(&tid, NULL, some_fn, NULL);
}
tid malloc 'd. tid , valgrind, _Unwind_ForcedUnwind, , *thread .