![](https://csdnimg.cn/release/download_crawler_static/3308754/bg3.jpg)
Advanced Linux Programming M. Barbeau
pthread_t pthread_self(void);
pthread_self returns the thread identifier for the calling thread.
pthread_detach()
#include <pthread.h>
int pthread_detach(pthread_t th);
pthread_detach put the thread th in the detached state. This guarantees
that the memory resources consumed by th will be freed immediately when
th terminates. However, this prevents other threads from synchronising on
the termination of th using pthread_join. The thread becomes non
joinable. The thread is like a daemon process.
On success, 0 is returned. On error, a non-zero error code is returned.
Example. A thread may detach itself by executing the following combination
of functions:
pthread_detach(pthread_self());
pthread_exit()
#include <pthread.h>
void pthread_exit(void *retval);
pthread_exit terminates the execution of the calling thread.
The retval argument is the return value of the thread. It can be consulted
from another thread using pthread_join().
3