Reputation: 393
Suppose i create a thread that ,in some point, calls a function foo(). If i call pthread_exit() from within foo, will that have as a result termination of the thread that called foo?
thanks, Nikos
Upvotes: 1
Views: 208
Reputation: 24907
Sure - thread context is unaffected by call/return. The thread IS calling pthread_exit(), no matter how long the call stack is. If 20 threads call foo then all 20 threads will exit.
Rgds, Martin
Upvotes: 0
Reputation: 5182
Of course. Otherwise what's the point of pthread_exit in the first place. http://www.kernel.org/doc/man-pages/online/pages/man3/pthread_exit.3.html "The pthread_exit() function shall terminate the calling thread"
Upvotes: 2
Reputation:
Yes, of course. It will also result in calling cleanup code, if any. Beware that it won't automatically clean application resources like mutexes etc. See pthread_exit() documentation for more information.
Upvotes: 0
Reputation:
From the documentation:
The pthread_exit() function terminates the calling thread
Upvotes: 0