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(S) function

   void thr_exit(
   	void *status
   );
where

status
is the address returned to another thread that has called thr_join(S).
The call to thr_exit(S) 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(S) (except for the initial thread, see ``Termination of the process'').

The thr_exit(S) 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(S) is limited to a small range of integers. The status returned by thr_exit(S) 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

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005