PTHREAD_JOIN

Section: C Library Functions (3)
Updated: LinuxThreads
Index Retour au Menu Principal


 

NOM

pthread_join - attend la mort d'un autre thread

 

SYNOPSIS

#include <pthread.h>

int pthread_join(pthread_t th, void **thread_return);

 

DESCRIPTION

pthread_join suspend l'exécution du thread appelant jusqu'à ce que le thread identifié par th achève son exécution, soit en appelant pthread_exit(3) soit après avoir été annullé.

Si thread_return ne vaut pas NULL, la valeur renvoyée par th y sera enregistrée. Cette valeur sera soit l'argument passé à pthread_exit(3), soit PTHREAD_CANCELED si le thread th a été annullé.

Le thread joint th doit être dans l'état joignable: il ne doit pas avoir été détaché par pthread_detach(3) ou par l'attribut PTHREAD_CREATE_DETACHED lors de sa création par pthread_create(3).

Quand l'exécution d'un thread joignable s'achève, ses ressources mémoires (descripteur de thread et pile) ne sont pas désallouées jusqu'à ce qu'un autre thread le joigne en utilisant pthread_join. Aussi, pthread_join doit être appelée une fois pour chaque thread joignable pour éviter des "fuites" de mémoire.

Au plus un seul thread peut attendre la mort d'un thread donné. Appeler pthread_join sur un thread th dont un autre thread attend déjà la fin renvoie une erreur.

 

ANNULLATION

pthread_join est un point d'annullation. Si un thread est annulé alors qu'il est suspendu dans pthread_join, l'exécution du thread reprend immédiatement et l'annulation est réalisée sans attendre la fin du thread th. Si l'annulation intervient durant pthread_join, le thread th demeure non joint.

 

VALEUR RENVOYÉE

En cas de succès, le code renvoyé par th est enregistré à l'emplacement pointé par thread_return, et 0 est renvoyé. En cas d'erreur, un code d'erreur non nul est renvoyé.

 

ERREURS

ESRCH
Aucun thread correspondant à th n' a pu être trouvé.
EINVAL
Le thread th a été détaché.
EINVAL
Un autre thread attend déjà la mort de th.
EDEADLK
L'argument th représente le thread appelant.

 

AUTEUR

Xavier Leroy <Xavier.Leroy@inria.fr>

 

TRADUCTION

Thierry Vignaud <tvignaud@mandrakesoft.com>, 2000

 

VOIR AUSSI

pthread_exit(3), pthread_detach(3), pthread_create(3), pthread_attr_setdetachstate(3), pthread_cleanup_push(3), pthread_key_create(3).



 

Index

NOM
SYNOPSIS
DESCRIPTION
ANNULLATION
VALEUR RENVOYÉE
ERREURS
AUTEUR
TRADUCTION
VOIR AUSSI


Time: 22:30:04 GMT, December 19, 2004