thr_exit

Terminates the calling thread.

Library:LibC
Classification:UNIX International
Service:Threads

Syntax

  #include <thread.h>
   
  void thr_exit (
    void   *status);
  

Parameters

status

(IN) Points to an application-defined exit value for the thread.

Remarks

When an application thread calls thr_exit, the thread is terminated. If it was created as a joinable thread, its exit value is returned to the sibling thread that successfully performs the thr_join operation on this departing thread.

When a detached thread exits, it cleans up after itself automatically. However, when a joinable thread exists and a thread is not already waiting to join the exiting thread, the system maintains sufficient state to support subsequent calls to thr_join. If you do not call thr_join on an exited joinable thread, system resources are held up unnecessarily.

When the process is terminated, all resources allocated to the process are freed. If the departing thread is the last application thread in the process, thr_exit terminates the containing process. When the thread executing main calls thr_exit, the process is not torn down unless this thread is also the last application thread.

See Also