I need pthread_exit if I don't need the return value

If I don't need the return status of my thread, do I need to have pthread_exit?

I am wondering if there could be any subtle resource issues related to not calling pthread_exit in my datached pthreads.

Thanks.

+4
source share
2 answers

You do not need to call pthread_exit() . Returning from the stream function will work equally well and there will be no leakage of any resources (of course, you should still make sure that your code has no leaks).

+3
source

The purpose of pthread_exit() is to return the exit code if any other threads join.

From the manual:

  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 exit status. 

So, it does not matter if you are not using it.

+5
source

All Articles