Multithreaded Programming Guide

Terminating a Thread

Use pthread_exit(3C) to terminate a thread.

pthread_exit Syntax

void	 pthread_exit(void *status);
#include <pthread.h>
void *status;
pthread_exit(status); /* exit with status */

The pthread_exit() function terminates the calling thread. All thread-specific data bindings are released. If the calling thread is not detached, then the thread's ID and the exit status specified by status are retained until your application calls pthread_join() to wait for the thread. Otherwise, status is ignored. The thread's ID can be reclaimed immediately. For information on thread detachment, see Setting Detach State.

pthread_exit Return Values

The calling thread terminates with its exit status set to the contents of status.