Does the process automatically clear resources received by pthreads on exit

Suppose I have code like this:

void *my_thread(void *data)
{
    while (1) { }
}

void foo_init(struct my_resource *res)
{
    pthread_create(&res->tid, NULL, my_thread, res);

    /* Some init code */
}

void foo_exit(void)
{
    /* Some exit code */
}

The script looks something like this. When the process is initialized, the function foo_init()is called with a pointer to my allocated resources (the allocation is performed automatically by another function that is not under my control). Inside the function, I create pthreadone that runs in an infinite loop.

After a while, when the process is about to end, the function is called foo_exit(), but this time without a pointer to my resources and, therefore, I can not call pthread_join(), since mine is tidcontained in the structure my_resource.

, , pthreads ? , .

pthread_join()?

.

+4
3

, . , , , , , .

, . ( RPC), .

, , . - ?

+4

"" , , (, , , ). , , , .

, , , , , , .

0

, : pthreads , . (Pthread "" , , malloc'ed, .) , pthreads , .

POSIX ( _Exit()):

• , _Exit() _exit(), .

exit() POSIX - , atexit() .. - , _Exit(). , pthread pthread - , - pthread, pthread_cancel() pthreads, , , .

Single UNIX® Specification (POSIX) - , , .

0

All Articles