PTHREAD_EXIT(3) Library Functions Manual PTHREAD_EXIT(3)NAME
pthread_exit - terminate the calling thread
SYNOPSIS
#include <pthread.h>
void pthread_exit(void *retval);
DESCRIPTION
pthread_exit terminates the execution of the calling thread. All cleanup handlers that have been set for the calling thread with
pthread_cleanup_push(3) are executed in reverse order (the most recently pushed handler is executed first). Finalization functions for
thread-specific data are then called for all keys that have non- NULL values associated with them in the calling thread (see
pthread_key_create(3)). Finally, execution of the calling thread is stopped.
The retval argument is the return value of the thread. It can be consulted from another thread using pthread_join(3).
RETURN VALUE
The pthread_exit function never returns.
AUTHOR
Xavier Leroy <Xavier.Leroy@inria.fr>
SEE ALSO pthread_create(3), pthread_join(3).
LinuxThreads PTHREAD_EXIT(3)
Check Out this Related Man Page
PTHREAD_JOIN(3) Library Functions Manual PTHREAD_JOIN(3)NAME
pthread_join - wait for termination of another thread
SYNOPSIS
#include <pthread.h>
int pthread_join(pthread_t th, void **thread_return);
DESCRIPTION
pthread_join suspends the execution of the calling thread until the thread identified by th terminates, either by calling pthread_exit(3)
or by being cancelled.
If thread_return is not NULL, the return value of th is stored in the location pointed to by thread_return. The return value of th is
either the argument it gave to pthread_exit(3), or PTHREAD_CANCELED if th was cancelled.
The joined thread th must be in the joinable state: it must not have been detached using pthread_detach(3) or the PTHREAD_CREATE_DETACHED
attribute to pthread_create(3).
When a joinable thread terminates, its memory resources (thread descriptor and stack) are not deallocated until another thread performs
pthread_join on it. Therefore, pthread_join must be called once for each joinable thread created to avoid memory leaks.
At most one thread can wait for the termination of a given thread. Calling pthread_join on a thread th on which another thread is already
waiting for termination returns an error.
CANCELLATION
pthread_join is a cancellation point. If a thread is canceled while suspended in pthread_join, the thread execution resumes immediately and
the cancellation is executed without waiting for the th thread to terminate. If cancellation occurs during pthread_join, the th thread
remains not joined.
RETURN VALUE
On success, the return value of th is stored in the location pointed to by thread_return, and 0 is returned. On error, a non-zero error
code is returned.
ERRORS
ESRCH No thread could be found corresponding to that specified by th.
EINVAL The th thread has been detached.
EINVAL Another thread is already waiting on termination of th.
EDEADLK
The th argument refers to the calling thread.
AUTHOR
Xavier Leroy <Xavier.Leroy@inria.fr>
SEE ALSO pthread_exit(3), pthread_detach(3), pthread_create(3), pthread_attr_setdetachstate(3), pthread_cleanup_push(3), pthread_key_create(3).
LinuxThreads PTHREAD_JOIN(3)
Hi,
I was trying to find from the function which is called by some other function but is it possiable by the calling funcation that who is calling me? For example
int function1()
{
// do something
return 0 ;
}
char function2()
{
// do something
function1() ; // is... (9 Replies)
When I use some of the pthread functions: pthread_join, pthread_exit they work perfect. But when I look in the pthread.h file I can't seem to find any implementations of the functions...where are they hiding?? (2 Replies)
I would like to make my own implementations of some of the pthread functions (pthread_exit(), pthread_join() etc.).
Does someone have any idea on how to get started doing this?? (1 Reply)
hi
i have a code:
I found that after exiting from child thread memory isn't freed. I commented everything which is "some actions" here, so thread's function contains only two lines. But it doesn't help.
What do I do wrong?
Thanks a lot (3 Replies)
We had written an application in which we create worker thread.
So the main thread will create the worker thread. After some time
the child thread(Worker thread) will call pthread_exit().
This function was written in try{} and there occured an Exception
and is handled in catch(...)... (0 Replies)
hi all,
my requirement is to create a thread by calling another function.
i.e i dont call pthread_create directly from main, but by calling another function (createThd - below ), from main.
Example:
void *thread_function(void *arg) { /* thread function */
int i;
rc =... (3 Replies)
Main function creates Thread0 and Thread1 by using pthread_create systemcall.
In Thread0() {
we are calling pthread_exit(0) ;
}
and in Thread1() {
status= pthread_join(tid,NULL);
sprintf(ebuf,"timer6: can't join with thread0, status: %d",status);
Assert(status==0,ebuf);
}
... (4 Replies)
C calling convention we all know defines a way how the parameters are pushed onto the stack.
My question is when and how does this C calling conventions matters to a user?
When the user will have to bother about the calling conventions in his project? (5 Replies)
The following thread is closed: 133552-howto-linux-multihomed-dns-client (Sorry I am not allowed to post URLs)
Therefore I write this append in an own thread.
The HOWTO in the referenced thread helped me a lot and I only want to append how to make reverse lookup working for a local zone:
... (0 Replies)
Hi,
I am new to multithreaded programming. When creating a thread to run a specific function, does the function need to have a pthread_exit ?
Is pthread_exit analogous to a return in a function? (3 Replies)
Thanks Ravinder for quick reply.Thats work.
One more thing if i want to extract something based on paranthesis....can you help.
Input:
exp1:
CREATE TABLE
(
A,
B,
C
)
o/p exp1:
A,
B,
C
exp2: (7 Replies)