DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Threads

Terminating a thread

A thread can terminate itself by using the thr_exit(3thread) function

   void thr_exit(
   	void *status
   );
where

status
is the address returned to another thread that has called thr_join(3thread).
The call to thr_exit(3thread) initiates automatic clean-up for thread resources:

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.

Termination of the process

There are three ways to terminate a threads process.


Next topic: Waiting for thread termination
Previous topic: Creating a new thread

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004