Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pthread_exit(3) [redhat man page]

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_EXIT(3) 					     Linux Programmer's Manual						   PTHREAD_EXIT(3)

NAME
pthread_exit - terminate calling thread SYNOPSIS
#include <pthread.h> void pthread_exit(void *retval); Compile and link with -pthread. DESCRIPTION
The pthread_exit() function terminates the calling thread and returns a value via retval that (if the thread is joinable) is available to another thread in the same process that calls pthread_join(3). Any clean-up handlers established by pthread_cleanup_push(3) that have not yet been popped, are popped (in the reverse of the order in which they were pushed) and executed. If the thread has any thread-specific data, then, after the clean-up handlers have been executed, the corresponding destructor functions are called, in an unspecified order. When a thread terminates, process-shared resources (e.g., mutexes, condition variables, semaphores, and file descriptors) are not released, and functions registered using atexit(3) are not called. After the last thread in a process terminates, the process terminates as by calling exit(3) with an exit status of zero; thus, process- shared resources are released and functions registered using atexit(3) are called. RETURN VALUE
This function does not return to the caller. ERRORS
This function always succeeds. CONFORMING TO
POSIX.1-2001. NOTES
Performing a return from the start function of any thread other than the main thread results in an implicit call to pthread_exit(), using the function's return value as the thread's exit status. To allow other threads to continue execution, the main thread should terminate by calling pthread_exit() rather than exit(3). The value pointed to by retval should not be located on the calling thread's stack, since the contents of that stack are undefined after the thread terminates. BUGS
Currently, there are limitations in the kernel implementation logic for wait(2)ing on a stopped thread group with a dead thread group leader. This can manifest in problems such as a locked terminal if a stop signal is sent to a foreground process whose thread group leader has already called pthread_exit(3). SEE ALSO
pthread_create(3), pthread_join(3), pthreads(7) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2009-03-30 PTHREAD_EXIT(3)
Man Page

13 More Discussions You Might Find Interesting

1. Programming

How to Find who is calling me?

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)
Discussion started by: uxbala
9 Replies

2. UNIX for Dummies Questions & Answers

Where are the pthread functions??

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)
Discussion started by: bigblop
2 Replies

3. Programming

Implementing my own pthread functions

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)
Discussion started by: bigblop
1 Replies

4. UNIX for Dummies Questions & Answers

Deleting old directries

All I want to delete all directories which are modified or created two days before in AIX. Thanx in advance Regards Deepak Xavier (1 Reply)
Discussion started by: DeepakXavier
1 Replies

5. Programming

Problem with pthreads

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)
Discussion started by: sery0ga
3 Replies

6. UNIX for Advanced & Expert Users

FATAL:exception occured with pthread_exit()

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)
Discussion started by: platso
0 Replies

7. Programming

create a thread from a returning function

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)
Discussion started by: wolwy_pete
3 Replies

8. Programming

Doubt on pthread_exit and pthread_join

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)
Discussion started by: mansa
4 Replies

9. Programming

pthread_exit and pthread_join usage

Hi... this simple code has warning messages but it work.. void *th(void *g){ int y = 10; pthread_exit((void*)y); } int main(int argn, char ** argp){ void * ret; pthread_t thread; pthread_create(&thread, NULL, th, NULL); pthread_join(thread,... (10 Replies)
Discussion started by: prompt
10 Replies

10. Programming

c calling conventions

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)
Discussion started by: rupeshkp728
5 Replies

11. IP Networking

HOWTO: Linux multihomed dns client - reverse lookup

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)
Discussion started by: scheruga
0 Replies

12. Programming

pthread_exit query

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)
Discussion started by: sanjayc
3 Replies

13. UNIX for Beginners Questions & Answers

Extract data between two parenthesi

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)
Discussion started by: raju2016
7 Replies