|
|
A thread can terminate itself by using the thr_exit(3thread) function
void thr_exit( void *status );where
The Threads Library arranges for a simple return from the start_routine to be equivalent to a call to thr_exit(3thread) (except for the initial thread, see ``Termination of the process'').
The thr_exit(3thread) function allows one thread to return a value called status to another; however, this mechanism is more general than the exit status returned by a child process to its parent. The argument to exit(2) is limited to a small range of integers. The status returned by thr_exit(3thread) is a general pointer that can be used (with type casts) to direct the receiver to objects of greater complexity such as structures, arrays, and linked lists. Of course, both the terminating and receiving threads should be coded to employ the same convention.
There are three ways to terminate a threads process.
A thread is categorized as a daemon thread at the time of its creation by use of the THR_DAEMON flag to thr_create(3thread).