version 1.9, 2010/04/21 13:45:50
|
version 1.51, 2011/06/21 07:45:27
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.15 |
RPL/2 (R) version 4.1.0.prerelease.1 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2011 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 20
|
Line 20
|
*/ |
*/ |
|
|
|
|
#include "rpl.conv.h" |
#include "rpl-conv.h" |
|
|
|
|
/* |
/* |
Line 82 insertion_thread(struct_processus *s_eta
|
Line 82 insertion_thread(struct_processus *s_eta
|
sigfillset(&set); |
sigfillset(&set); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
|
|
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&semaphore_liste_threads) == -1) |
|
# else |
|
while(sem_wait(semaphore_liste_threads) == -1) |
|
# endif |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
if ((l_nouvel_objet = malloc(sizeof(struct_liste_chainee_volatile))) |
if ((l_nouvel_objet = malloc(sizeof(struct_liste_chainee_volatile))) |
== NULL) |
== NULL) |
{ |
{ |
# ifndef SEMAPHORES_NOMMES |
|
sem_post(&semaphore_liste_threads); |
|
# else |
|
sem_post(semaphore_liste_threads); |
|
# endif |
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
|
|
Line 113 insertion_thread(struct_processus *s_eta
|
Line 92 insertion_thread(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
(*l_nouvel_objet).suivant = liste_threads; |
|
|
|
if (((*l_nouvel_objet).donnee = malloc(sizeof(struct_thread))) == NULL) |
if (((*l_nouvel_objet).donnee = malloc(sizeof(struct_thread))) == NULL) |
{ |
{ |
# ifndef SEMAPHORES_NOMMES |
|
sem_post(&semaphore_liste_threads); |
|
# else |
|
sem_post(semaphore_liste_threads); |
|
# endif |
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
|
|
Line 136 insertion_thread(struct_processus *s_eta
|
Line 108 insertion_thread(struct_processus *s_eta
|
(*((struct_thread *) (*l_nouvel_objet).donnee)).s_etat_processus = |
(*((struct_thread *) (*l_nouvel_objet).donnee)).s_etat_processus = |
s_etat_processus; |
s_etat_processus; |
|
|
|
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&semaphore_liste_threads) == -1) |
|
# else |
|
while(sem_wait(semaphore_liste_threads) == -1) |
|
# endif |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
(*l_nouvel_objet).suivant = liste_threads; |
liste_threads = l_nouvel_objet; |
liste_threads = l_nouvel_objet; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
Line 168 insertion_thread_surveillance(struct_pro
|
Line 157 insertion_thread_surveillance(struct_pro
|
sigfillset(&set); |
sigfillset(&set); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
|
|
|
if ((l_nouvel_objet = malloc(sizeof(struct_liste_chainee_volatile))) |
|
== NULL) |
|
{ |
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return; |
|
} |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&semaphore_liste_threads) == -1) |
while(sem_wait(&semaphore_liste_threads) == -1) |
# else |
# else |
Line 184 insertion_thread_surveillance(struct_pro
|
Line 183 insertion_thread_surveillance(struct_pro
|
} |
} |
} |
} |
|
|
if ((l_nouvel_objet = malloc(sizeof(struct_liste_chainee_volatile))) |
pthread_mutex_lock(&((*s_argument_thread).mutex_nombre_references)); |
== NULL) |
(*s_argument_thread).nombre_references++; |
{ |
pthread_mutex_unlock(&((*s_argument_thread).mutex_nombre_references)); |
# ifndef SEMAPHORES_NOMMES |
|
sem_post(&semaphore_liste_threads); |
|
# else |
|
sem_post(semaphore_liste_threads); |
|
# endif |
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
(*l_nouvel_objet).suivant = liste_threads_surveillance; |
(*l_nouvel_objet).suivant = liste_threads_surveillance; |
(*l_nouvel_objet).donnee = (void *) s_argument_thread; |
(*l_nouvel_objet).donnee = (void *) s_argument_thread; |
Line 289 retrait_thread(struct_processus *s_etat_
|
Line 277 retrait_thread(struct_processus *s_etat_
|
(*l_element_precedent).suivant = (*l_element_courant).suivant; |
(*l_element_precedent).suivant = (*l_element_courant).suivant; |
} |
} |
|
|
free((void *) (*l_element_courant).donnee); |
|
free((struct_liste_chainee_volatile *) l_element_courant); |
|
|
|
if (pthread_setspecific(semaphore_fork_processus_courant, NULL) != 0) |
if (pthread_setspecific(semaphore_fork_processus_courant, NULL) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
Line 319 retrait_thread(struct_processus *s_etat_
|
Line 304 retrait_thread(struct_processus *s_etat_
|
return; |
return; |
} |
} |
|
|
|
free((void *) (*l_element_courant).donnee); |
|
free((struct_liste_chainee_volatile *) l_element_courant); |
|
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
return; |
return; |
Line 390 retrait_thread_surveillance(struct_proce
|
Line 378 retrait_thread_surveillance(struct_proce
|
(*l_element_precedent).suivant = (*l_element_courant).suivant; |
(*l_element_precedent).suivant = (*l_element_courant).suivant; |
} |
} |
|
|
free((struct_liste_chainee_volatile *) l_element_courant); |
if (pthread_mutex_lock(&((*s_argument_thread).mutex_nombre_references)) |
|
!= 0) |
if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0) |
|
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
|
sem_post(&semaphore_liste_threads); |
|
# else |
|
sem_post(semaphore_liste_threads); |
|
# endif |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
|
|
Line 409 retrait_thread_surveillance(struct_proce
|
Line 401 retrait_thread_surveillance(struct_proce
|
|
|
if ((*s_argument_thread).nombre_references == 0) |
if ((*s_argument_thread).nombre_references == 0) |
{ |
{ |
if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_argument_thread) |
|
.mutex_nombre_references)) != 0) |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
|
sem_post(&semaphore_liste_threads); |
|
# else |
|
sem_post(semaphore_liste_threads); |
|
# endif |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
|
|
Line 419 retrait_thread_surveillance(struct_proce
|
Line 417 retrait_thread_surveillance(struct_proce
|
} |
} |
|
|
pthread_mutex_destroy(&((*s_argument_thread).mutex)); |
pthread_mutex_destroy(&((*s_argument_thread).mutex)); |
|
pthread_mutex_destroy(&((*s_argument_thread).mutex_nombre_references)); |
free(s_argument_thread); |
free(s_argument_thread); |
} |
} |
else |
else |
{ |
{ |
if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_argument_thread) |
|
.mutex_nombre_references)) != 0) |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
|
sem_post(&semaphore_liste_threads); |
|
# else |
|
sem_post(semaphore_liste_threads); |
|
# endif |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
|
|
Line 446 retrait_thread_surveillance(struct_proce
|
Line 451 retrait_thread_surveillance(struct_proce
|
return; |
return; |
} |
} |
|
|
|
free((struct_liste_chainee_volatile *) l_element_courant); |
|
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
sigpending(&set); |
sigpending(&set); |
|
|
return; |
return; |
} |
} |
|
|
Line 626 liberation_threads(struct_processus *s_e
|
Line 634 liberation_threads(struct_processus *s_e
|
close((*s_etat_processus).pipe_nombre_objets_attente); |
close((*s_etat_processus).pipe_nombre_objets_attente); |
close((*s_etat_processus).pipe_nombre_interruptions_attente); |
close((*s_etat_processus).pipe_nombre_interruptions_attente); |
|
|
|
liberation(s_etat_processus, (*s_etat_processus).at_exit); |
|
|
if ((*s_etat_processus).nom_fichier_impression != NULL) |
if ((*s_etat_processus).nom_fichier_impression != NULL) |
{ |
{ |
free((*s_etat_processus).nom_fichier_impression); |
free((*s_etat_processus).nom_fichier_impression); |
Line 667 liberation_threads(struct_processus *s_e
|
Line 677 liberation_threads(struct_processus *s_e
|
.l_base_pile_processus; |
.l_base_pile_processus; |
while(element_courant != NULL) |
while(element_courant != NULL) |
{ |
{ |
pthread_mutex_trylock(&((*(*((struct_liste_chainee *) |
s_argument_thread = (struct_descripteur_thread *) |
element_courant)).donnee).mutex)); |
(*((struct_liste_chainee *) element_courant)).donnee; |
pthread_mutex_unlock(&((*(*((struct_liste_chainee *) |
|
element_courant)).donnee).mutex)); |
if (pthread_mutex_lock(&((*s_argument_thread) |
liberation(s_etat_processus, |
.mutex_nombre_references)) != 0) |
(*((struct_liste_chainee *) element_courant)).donnee); |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
sem_post(&semaphore_liste_threads); |
|
return; |
|
} |
|
|
|
(*s_argument_thread).nombre_references--; |
|
|
|
BUG((*s_argument_thread).nombre_references < 0, |
|
printf("(*s_argument_thread).nombre_references = %d\n", |
|
(int) (*s_argument_thread).nombre_references)); |
|
|
|
if ((*s_argument_thread).nombre_references == 0) |
|
{ |
|
close((*s_argument_thread).pipe_objets[0]); |
|
close((*s_argument_thread).pipe_acquittement[1]); |
|
close((*s_argument_thread).pipe_injections[1]); |
|
close((*s_argument_thread).pipe_nombre_injections[1]); |
|
close((*s_argument_thread).pipe_nombre_objets_attente[0]); |
|
close((*s_argument_thread).pipe_interruptions[0]); |
|
close((*s_argument_thread) |
|
.pipe_nombre_interruptions_attente[0]); |
|
|
|
if (pthread_mutex_unlock(&((*s_argument_thread) |
|
.mutex_nombre_references)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
sem_post(&semaphore_liste_threads); |
|
return; |
|
} |
|
|
|
pthread_mutex_destroy(&((*s_argument_thread).mutex)); |
|
pthread_mutex_destroy(&((*s_argument_thread) |
|
.mutex_nombre_references)); |
|
|
|
if ((*s_argument_thread).processus_detache == d_faux) |
|
{ |
|
if ((*s_argument_thread).destruction_objet == d_vrai) |
|
{ |
|
liberation(s_etat_processus, (*s_argument_thread) |
|
.argument); |
|
} |
|
} |
|
|
|
free(s_argument_thread); |
|
} |
|
else |
|
{ |
|
if (pthread_mutex_unlock(&((*s_argument_thread) |
|
.mutex_nombre_references)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
sem_post(&semaphore_liste_threads); |
|
return; |
|
} |
|
} |
|
|
element_suivant = (*((struct_liste_chainee *) element_courant)) |
element_suivant = (*((struct_liste_chainee *) element_courant)) |
.suivant; |
.suivant; |
free((struct_liste_chainee *) element_courant); |
free(element_courant); |
element_courant = element_suivant; |
element_courant = element_suivant; |
} |
} |
|
|
|
(*s_etat_processus).l_base_pile_processus = NULL; |
|
|
pthread_mutex_trylock(&((*(*s_etat_processus).indep).mutex)); |
pthread_mutex_trylock(&((*(*s_etat_processus).indep).mutex)); |
pthread_mutex_unlock(&((*(*s_etat_processus).indep).mutex)); |
pthread_mutex_unlock(&((*(*s_etat_processus).indep).mutex)); |
liberation(s_etat_processus, (*s_etat_processus).indep); |
liberation(s_etat_processus, (*s_etat_processus).indep); |
Line 735 liberation_threads(struct_processus *s_e
|
Line 803 liberation_threads(struct_processus *s_e
|
} |
} |
} |
} |
|
|
|
#if 0 |
for(i = 0; i < (*s_etat_processus).nombre_variables; i++) |
for(i = 0; i < (*s_etat_processus).nombre_variables; i++) |
{ |
{ |
pthread_mutex_trylock(&((*(*s_etat_processus) |
pthread_mutex_trylock(&((*(*s_etat_processus) |
Line 754 liberation_threads(struct_processus *s_e
|
Line 823 liberation_threads(struct_processus *s_e
|
} |
} |
|
|
free((*s_etat_processus).s_liste_variables); |
free((*s_etat_processus).s_liste_variables); |
|
#endif |
|
|
for(i = 0; i < (*s_etat_processus).nombre_variables_statiques; i++) |
for(i = 0; i < (*s_etat_processus).nombre_variables_statiques; i++) |
{ |
{ |
Line 1153 liberation_threads(struct_processus *s_e
|
Line 1223 liberation_threads(struct_processus *s_e
|
element_courant = element_suivant; |
element_courant = element_suivant; |
} |
} |
|
|
|
/* |
|
================================================================================ |
|
À noter : on ne ferme pas la connexion car la conséquence immédiate est |
|
une destruction de l'objet pour le processus père. |
|
================================================================================ |
|
|
element_courant = (*s_etat_processus).s_connecteurs_sql; |
element_courant = (*s_etat_processus).s_connecteurs_sql; |
while(element_courant != NULL) |
while(element_courant != NULL) |
{ |
{ |
Line 1236 liberation_threads(struct_processus *s_e
|
Line 1312 liberation_threads(struct_processus *s_e
|
|
|
element_courant = element_suivant; |
element_courant = element_suivant; |
} |
} |
|
*/ |
|
|
|
(*s_etat_processus).s_connecteurs_sql = NULL; |
|
|
element_courant = (*s_etat_processus).s_marques; |
element_courant = (*s_etat_processus).s_marques; |
while(element_courant != NULL) |
while(element_courant != NULL) |
Line 1280 liberation_threads(struct_processus *s_e
|
Line 1359 liberation_threads(struct_processus *s_e
|
s_argument_thread = (struct_descripteur_thread *) |
s_argument_thread = (struct_descripteur_thread *) |
(*l_element_courant).donnee; |
(*l_element_courant).donnee; |
|
|
close((*s_argument_thread).pipe_objets[0]); |
if (pthread_mutex_lock(&((*s_argument_thread).mutex_nombre_references)) |
close((*s_argument_thread).pipe_acquittement[1]); |
!= 0) |
close((*s_argument_thread).pipe_injections[1]); |
|
close((*s_argument_thread).pipe_nombre_injections[1]); |
|
close((*s_argument_thread).pipe_nombre_objets_attente[0]); |
|
close((*s_argument_thread).pipe_interruptions[0]); |
|
close((*s_argument_thread).pipe_nombre_interruptions_attente[0]); |
|
|
|
if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
sem_post(&semaphore_liste_threads); |
return; |
return; |
} |
} |
|
|
Line 1302 liberation_threads(struct_processus *s_e
|
Line 1375 liberation_threads(struct_processus *s_e
|
|
|
if ((*s_argument_thread).nombre_references == 0) |
if ((*s_argument_thread).nombre_references == 0) |
{ |
{ |
if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0) |
close((*s_argument_thread).pipe_objets[0]); |
|
close((*s_argument_thread).pipe_acquittement[1]); |
|
close((*s_argument_thread).pipe_injections[1]); |
|
close((*s_argument_thread).pipe_nombre_injections[1]); |
|
close((*s_argument_thread).pipe_nombre_objets_attente[0]); |
|
close((*s_argument_thread).pipe_interruptions[0]); |
|
close((*s_argument_thread).pipe_nombre_interruptions_attente[0]); |
|
|
|
if (pthread_mutex_unlock(&((*s_argument_thread) |
|
.mutex_nombre_references)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
sem_post(&semaphore_liste_threads); |
return; |
return; |
} |
} |
|
|
pthread_mutex_destroy(&((*s_argument_thread).mutex)); |
pthread_mutex_destroy(&((*s_argument_thread).mutex)); |
|
pthread_mutex_destroy(&((*s_argument_thread) |
|
.mutex_nombre_references)); |
|
|
|
if ((*s_argument_thread).processus_detache == d_faux) |
|
{ |
|
if ((*s_argument_thread).destruction_objet == d_vrai) |
|
{ |
|
liberation(s_etat_processus, (*s_argument_thread).argument); |
|
} |
|
} |
|
|
free(s_argument_thread); |
free(s_argument_thread); |
} |
} |
else |
else |
{ |
{ |
if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_argument_thread) |
|
.mutex_nombre_references)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
sem_post(&semaphore_liste_threads); |
return; |
return; |
} |
} |
} |
} |
Line 1426 recherche_thread_principal(pid_t pid, pt
|
Line 1522 recherche_thread_principal(pid_t pid, pt
|
*/ |
*/ |
|
|
// Les routines suivantes sont uniquement appelées depuis les gestionnaires |
// Les routines suivantes sont uniquement appelées depuis les gestionnaires |
// des signaux asynchrones. Elles de doivent pas bloquer dans le cas où |
// des signaux asynchrones. Elles ne doivent pas bloquer dans le cas où |
// les sémaphores sont déjà bloqués par un gestionnaire de signal. |
// les sémaphores sont déjà bloqués par un gestionnaire de signal. |
|
|
static inline void |
static inline void |
Line 1510 verrouillage_gestionnaire_signaux()
|
Line 1606 verrouillage_gestionnaire_signaux()
|
// ce que ce soit possible. |
// ce que ce soit possible. |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_trywait(&semaphore_liste_threads) == -1) |
while(sem_wait(&semaphore_liste_threads) == -1) |
# else |
# else |
while(sem_trywait(semaphore_liste_threads) == -1) |
while(sem_wait(semaphore_liste_threads) == -1) |
# endif |
# endif |
{ |
{ |
if ((errno != EINTR) && (errno != EAGAIN)) |
if (errno != EINTR) |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
|
Line 1531 verrouillage_gestionnaire_signaux()
|
Line 1627 verrouillage_gestionnaire_signaux()
|
BUG(1, uprintf("Lock error !\n")); |
BUG(1, uprintf("Lock error !\n")); |
return; |
return; |
} |
} |
|
|
sched_yield(); |
|
} |
} |
} |
} |
|
|
Line 1643 deverrouillage_gestionnaire_signaux()
|
Line 1737 deverrouillage_gestionnaire_signaux()
|
} |
} |
|
|
void |
void |
interruption1(int signal, siginfo_t *siginfo, void *context) |
interruption1(SIGHANDLER_ARGS) |
{ |
{ |
|
pid_t pid; |
|
|
pthread_t thread; |
pthread_t thread; |
|
|
struct_processus *s_etat_processus; |
struct_processus *s_etat_processus; |
Line 1653 interruption1(int signal, siginfo_t *sig
|
Line 1749 interruption1(int signal, siginfo_t *sig
|
|
|
verrouillage_gestionnaire_signaux(); |
verrouillage_gestionnaire_signaux(); |
|
|
|
# ifdef _BROKEN_SIGINFO |
|
if ((signal == SIGINT) || (signal == SIGTERM)) |
|
{ |
|
// Si l'interruption provient du clavier, il n'y a pas eu d'appel |
|
// à queue_in(). |
|
|
|
pid = getpid(); |
|
} |
|
else |
|
{ |
|
pid = origine_signal(signal); |
|
} |
|
# else |
|
if (siginfo != NULL) |
|
{ |
|
pid = (*siginfo).si_pid; |
|
} |
|
else |
|
{ |
|
pid = getpid(); |
|
} |
|
# endif |
|
|
switch(signal) |
switch(signal) |
{ |
{ |
case SIGALRM : |
case SIGALRM : |
{ |
{ |
if ((*siginfo).si_pid == getpid()) |
if (pid == getpid()) |
{ |
{ |
if ((s_etat_processus = recherche_thread(getpid(), |
if ((s_etat_processus = recherche_thread(getpid(), |
pthread_self())) == NULL) |
pthread_self())) == NULL) |
{ |
{ |
deverrouillage_gestionnaire_signaux(); |
deverrouillage_gestionnaire_signaux(); |
return; |
return; |
} |
} |
|
|
if (((*s_etat_processus).type_debug & d_debug_signaux) != 0) |
if (((*s_etat_processus).type_debug & d_debug_signaux) != 0) |
Line 1695 interruption1(int signal, siginfo_t *sig
|
Line 1814 interruption1(int signal, siginfo_t *sig
|
} |
} |
|
|
case SIGINT : |
case SIGINT : |
|
case SIGTERM : |
{ |
{ |
/* |
/* |
* Une vieille spécification POSIX permet au pointeur siginfo |
* Une vieille spécification POSIX permet au pointeur siginfo |
Line 1702 interruption1(int signal, siginfo_t *sig
|
Line 1822 interruption1(int signal, siginfo_t *sig
|
* Solaris suit en particulier cette spécification. |
* Solaris suit en particulier cette spécification. |
*/ |
*/ |
|
|
|
# ifndef _BROKEN_SIGINFO |
if (siginfo == NULL) |
if (siginfo == NULL) |
{ |
{ |
kill(getpid(), signal); |
kill(getpid(), signal); |
} |
} |
else if ((*siginfo).si_pid == getpid()) |
else |
|
# endif |
|
if (pid == getpid()) |
{ |
{ |
if ((s_etat_processus = recherche_thread(getpid(), |
if ((s_etat_processus = recherche_thread(getpid(), |
pthread_self())) == NULL) |
pthread_self())) == NULL) |
Line 1717 interruption1(int signal, siginfo_t *sig
|
Line 1840 interruption1(int signal, siginfo_t *sig
|
|
|
if (((*s_etat_processus).type_debug & d_debug_signaux) != 0) |
if (((*s_etat_processus).type_debug & d_debug_signaux) != 0) |
{ |
{ |
printf("[%d] SIGINT (thread %llu)\n", (int) getpid(), |
if (signal == SIGINT) |
(unsigned long long) pthread_self()); |
{ |
|
printf("[%d] SIGINT (thread %llu)\n", (int) getpid(), |
|
(unsigned long long) pthread_self()); |
|
} |
|
else |
|
{ |
|
printf("[%d] SIGTERM (thread %llu)\n", (int) getpid(), |
|
(unsigned long long) pthread_self()); |
|
} |
|
|
fflush(stdout); |
fflush(stdout); |
} |
} |
|
|
Line 1740 interruption1(int signal, siginfo_t *sig
|
Line 1872 interruption1(int signal, siginfo_t *sig
|
return; |
return; |
} |
} |
|
|
if (strncmp(getenv("LANG"), "fr", 2) == 0) |
if (signal == SIGINT) |
{ |
|
printf("+++Interruption\n"); |
|
} |
|
else |
|
{ |
{ |
printf("+++Interrupt\n"); |
if (strncmp(getenv("LANG"), "fr", 2) == 0) |
} |
{ |
|
printf("+++Interruption\n"); |
|
} |
|
else |
|
{ |
|
printf("+++Interrupt\n"); |
|
} |
|
|
fflush(stdout); |
fflush(stdout); |
|
} |
|
|
(*s_etat_processus).var_volatile_requete_arret = -1; |
(*s_etat_processus).var_volatile_requete_arret = -1; |
(*s_etat_processus).var_volatile_alarme = -1; |
(*s_etat_processus).var_volatile_alarme = -1; |
Line 1781 interruption1(int signal, siginfo_t *sig
|
Line 1916 interruption1(int signal, siginfo_t *sig
|
} |
} |
|
|
void |
void |
interruption2(int signal, siginfo_t *siginfo, void *context) |
interruption2(SIGHANDLER_ARGS) |
{ |
{ |
|
pid_t pid; |
|
|
pthread_t thread; |
pthread_t thread; |
|
|
struct_processus *s_etat_processus; |
struct_processus *s_etat_processus; |
|
|
verrouillage_gestionnaire_signaux(); |
verrouillage_gestionnaire_signaux(); |
|
|
|
# ifdef _BROKEN_SIGINFO |
|
pid = origine_signal(signal); |
|
# else |
|
if (siginfo != NULL) |
|
{ |
|
pid = (*siginfo).si_pid; |
|
} |
|
else |
|
{ |
|
pid = getpid(); |
|
} |
|
# endif |
|
|
|
# ifndef _BROKEN_SIGINFO |
if (siginfo == NULL) |
if (siginfo == NULL) |
{ |
{ |
/* |
/* |
Line 1805 interruption2(int signal, siginfo_t *sig
|
Line 1957 interruption2(int signal, siginfo_t *sig
|
return; |
return; |
} |
} |
} |
} |
else if ((*siginfo).si_pid == getpid()) |
else |
|
# endif |
|
if (pid == getpid()) |
{ |
{ |
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) |
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) |
== NULL) |
== NULL) |
Line 1853 interruption2(int signal, siginfo_t *sig
|
Line 2007 interruption2(int signal, siginfo_t *sig
|
} |
} |
|
|
void |
void |
interruption3(int signal, siginfo_t *siginfo, void *context) |
interruption3(SIGHANDLER_ARGS) |
{ |
{ |
|
pid_t pid; |
|
|
struct_processus *s_etat_processus; |
struct_processus *s_etat_processus; |
|
|
static int compteur = 0; |
static int compteur = 0; |
|
|
verrouillage_gestionnaire_signaux(); |
verrouillage_gestionnaire_signaux(); |
|
|
|
# ifdef _BROKEN_SIGINFO |
|
pid = origine_signal(signal); |
|
# else |
|
pid = (*siginfo).si_pid; |
|
# endif |
|
|
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL) |
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL) |
{ |
{ |
deverrouillage_gestionnaire_signaux(); |
deverrouillage_gestionnaire_signaux(); |
Line 1913 interruption3(int signal, siginfo_t *sig
|
Line 2075 interruption3(int signal, siginfo_t *sig
|
} |
} |
|
|
void |
void |
interruption4(int signal, siginfo_t *siginfo, void *context) |
interruption4(SIGHANDLER_ARGS) |
{ |
{ |
|
pid_t pid; |
|
|
struct_processus *s_etat_processus; |
struct_processus *s_etat_processus; |
|
|
verrouillage_gestionnaire_signaux(); |
verrouillage_gestionnaire_signaux(); |
|
|
|
# ifdef _BROKEN_SIGINFO |
|
pid = origine_signal(signal); |
|
# else |
|
pid = (*siginfo).si_pid; |
|
# endif |
|
|
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL) |
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL) |
{ |
{ |
deverrouillage_gestionnaire_signaux(); |
deverrouillage_gestionnaire_signaux(); |
Line 1941 interruption4(int signal, siginfo_t *sig
|
Line 2111 interruption4(int signal, siginfo_t *sig
|
} |
} |
|
|
void |
void |
interruption5(int signal, siginfo_t *siginfo, void *context) |
interruption5(SIGHANDLER_ARGS) |
{ |
{ |
|
pid_t pid; |
|
|
pthread_t thread; |
pthread_t thread; |
|
|
struct_processus *s_etat_processus; |
struct_processus *s_etat_processus; |
|
|
verrouillage_gestionnaire_signaux(); |
verrouillage_gestionnaire_signaux(); |
|
|
if ((*siginfo).si_pid == getpid()) |
# ifdef _BROKEN_SIGINFO |
|
pid = origine_signal(signal); |
|
# else |
|
pid = (*siginfo).si_pid; |
|
# endif |
|
|
|
if (pid == getpid()) |
{ |
{ |
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) |
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) |
== NULL) |
== NULL) |
Line 1982 interruption5(int signal, siginfo_t *sig
|
Line 2161 interruption5(int signal, siginfo_t *sig
|
} |
} |
else |
else |
{ |
{ |
|
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) |
|
== NULL) |
|
{ |
|
deverrouillage_gestionnaire_signaux(); |
|
return; |
|
} |
|
|
// Envoi d'un signal au thread maître du groupe. |
// Envoi d'un signal au thread maître du groupe. |
|
|
if (recherche_thread_principal(getpid(), &thread) == d_vrai) |
if (recherche_thread_principal(getpid(), &thread) == d_vrai) |
{ |
{ |
pthread_kill(thread, SIGFSTOP); |
pthread_kill(thread, signal); |
deverrouillage_gestionnaire_signaux(); |
deverrouillage_gestionnaire_signaux(); |
return; |
return; |
} |
} |
Line 1997 interruption5(int signal, siginfo_t *sig
|
Line 2183 interruption5(int signal, siginfo_t *sig
|
} |
} |
|
|
void |
void |
interruption6(int signal, siginfo_t *siginfo, void *context) |
interruption6(SIGHANDLER_ARGS) |
{ |
{ |
|
pid_t pid; |
|
|
struct_processus *s_etat_processus; |
struct_processus *s_etat_processus; |
|
|
verrouillage_gestionnaire_signaux(); |
verrouillage_gestionnaire_signaux(); |
|
|
|
# ifdef _BROKEN_SIGINFO |
|
pid = origine_signal(signal); |
|
# else |
|
pid = (*siginfo).si_pid; |
|
# endif |
|
|
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL) |
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL) |
{ |
{ |
deverrouillage_gestionnaire_signaux(); |
deverrouillage_gestionnaire_signaux(); |
Line 2021 interruption6(int signal, siginfo_t *sig
|
Line 2215 interruption6(int signal, siginfo_t *sig
|
} |
} |
|
|
void |
void |
interruption7(int signal, siginfo_t *siginfo, void *context) |
interruption7(SIGHANDLER_ARGS) |
{ |
{ |
|
pid_t pid; |
|
|
struct_processus *s_etat_processus; |
struct_processus *s_etat_processus; |
|
|
verrouillage_gestionnaire_signaux(); |
verrouillage_gestionnaire_signaux(); |
|
|
|
# ifdef _BROKEN_SIGINFO |
|
pid = origine_signal(signal); |
|
# else |
|
pid = (*siginfo).si_pid; |
|
# endif |
|
|
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL) |
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL) |
{ |
{ |
deverrouillage_gestionnaire_signaux(); |
deverrouillage_gestionnaire_signaux(); |
Line 2048 interruption7(int signal, siginfo_t *sig
|
Line 2250 interruption7(int signal, siginfo_t *sig
|
} |
} |
|
|
void |
void |
interruption8(int signal, siginfo_t *siginfo, void *context) |
interruption8(SIGHANDLER_ARGS) |
{ |
{ |
|
pid_t pid; |
|
|
pthread_t thread; |
pthread_t thread; |
|
|
struct_processus *s_etat_processus; |
struct_processus *s_etat_processus; |
|
|
verrouillage_gestionnaire_signaux(); |
verrouillage_gestionnaire_signaux(); |
|
|
if ((*siginfo).si_pid == getpid()) |
# ifdef _BROKEN_SIGINFO |
|
pid = origine_signal(signal); |
|
# else |
|
pid = (*siginfo).si_pid; |
|
# endif |
|
|
|
if (pid == getpid()) |
{ |
{ |
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) |
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) |
== NULL) |
== NULL) |
Line 2091 interruption8(int signal, siginfo_t *sig
|
Line 2302 interruption8(int signal, siginfo_t *sig
|
} |
} |
|
|
void |
void |
interruption9(int signal, siginfo_t *siginfo, void *context) |
interruption9(SIGHANDLER_ARGS) |
{ |
{ |
|
pid_t pid; |
|
|
struct_processus *s_etat_processus; |
struct_processus *s_etat_processus; |
|
|
verrouillage_gestionnaire_signaux(); |
verrouillage_gestionnaire_signaux(); |
|
|
|
# ifdef _BROKEN_SIGINFO |
|
pid = origine_signal(signal); |
|
# else |
|
pid = (*siginfo).si_pid; |
|
# endif |
|
|
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL) |
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL) |
{ |
{ |
deverrouillage_gestionnaire_signaux(); |
deverrouillage_gestionnaire_signaux(); |
Line 2110 interruption9(int signal, siginfo_t *sig
|
Line 2329 interruption9(int signal, siginfo_t *sig
|
fflush(stdout); |
fflush(stdout); |
} |
} |
|
|
pthread_kill((*s_etat_processus).tid_processus_pere, SIGFSTOP); |
# ifdef _BROKEN_SIGINFO |
|
if (queue_in(getpid(), signal) != 0) |
|
{ |
|
return; |
|
} |
|
|
|
deverrouillage_gestionnaire_signaux(); |
|
interruption11(signal); |
|
# else |
deverrouillage_gestionnaire_signaux(); |
deverrouillage_gestionnaire_signaux(); |
|
interruption11(signal, siginfo, context); |
|
# endif |
return; |
return; |
} |
} |
|
|
void |
void |
interruption10(int signal, siginfo_t *siginfo, void *context) |
interruption10(SIGHANDLER_ARGS) |
{ |
{ |
file *fichier; |
file *fichier; |
|
|
|
pid_t pid; |
|
|
struct_processus *s_etat_processus; |
struct_processus *s_etat_processus; |
|
|
unsigned char nom[8 + 64 + 1]; |
unsigned char nom[8 + 64 + 1]; |
|
|
verrouillage_gestionnaire_signaux(); |
verrouillage_gestionnaire_signaux(); |
|
|
|
# ifdef _BROKEN_SIGINFO |
|
pid = origine_signal(signal); |
|
# else |
|
pid = (*siginfo).si_pid; |
|
# endif |
|
|
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL) |
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) == NULL) |
{ |
{ |
deverrouillage_gestionnaire_signaux(); |
deverrouillage_gestionnaire_signaux(); |
Line 2153 interruption10(int signal, siginfo_t *si
|
Line 2390 interruption10(int signal, siginfo_t *si
|
} |
} |
|
|
deverrouillage_gestionnaire_signaux(); |
deverrouillage_gestionnaire_signaux(); |
|
return; |
|
} |
|
|
|
void |
|
interruption11(SIGHANDLER_ARGS) |
|
{ |
|
pid_t pid; |
|
|
|
pthread_t thread; |
|
|
|
struct_processus *s_etat_processus; |
|
|
|
verrouillage_gestionnaire_signaux(); |
|
|
|
# ifdef _BROKEN_SIGINFO |
|
pid = origine_signal(signal); |
|
# else |
|
pid = (*siginfo).si_pid; |
|
# endif |
|
|
|
if (pid == getpid()) |
|
{ |
|
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) |
|
== NULL) |
|
{ |
|
deverrouillage_gestionnaire_signaux(); |
|
return; |
|
} |
|
|
|
(*s_etat_processus).arret_depuis_abort = -1; |
|
|
|
if (((*s_etat_processus).type_debug & d_debug_signaux) != 0) |
|
{ |
|
printf("[%d] SIGFABORT (thread %llu)\n", (int) getpid(), |
|
(unsigned long long) pthread_self()); |
|
fflush(stdout); |
|
} |
|
|
|
/* |
|
* var_globale_traitement_retarde_stop : |
|
* 0 -> traitement immédiat |
|
* 1 -> traitement retardé (aucun signal reçu) |
|
* -1 -> traitement retardé (un ou plusieurs signaux stop reçus) |
|
*/ |
|
|
|
if ((*s_etat_processus).var_volatile_traitement_retarde_stop == 0) |
|
{ |
|
(*s_etat_processus).var_volatile_requete_arret = -1; |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).var_volatile_traitement_retarde_stop = -1; |
|
} |
|
} |
|
else |
|
{ |
|
if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) |
|
== NULL) |
|
{ |
|
deverrouillage_gestionnaire_signaux(); |
|
return; |
|
} |
|
|
|
(*s_etat_processus).arret_depuis_abort = -1; |
|
|
|
// Envoi d'un signal au thread maître du groupe. |
|
|
|
if (recherche_thread_principal(getpid(), &thread) == d_vrai) |
|
{ |
|
pthread_kill(thread, signal); |
|
deverrouillage_gestionnaire_signaux(); |
|
return; |
|
} |
|
} |
|
|
|
deverrouillage_gestionnaire_signaux(); |
return; |
return; |
} |
} |
|
|