--- rpl/src/instructions_p7.c 2013/12/03 09:36:14 1.58 +++ rpl/src/instructions_p7.c 2019/02/11 09:45:51 1.80 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.17 - Copyright (C) 1989-2013 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.31 + Copyright (C) 1989-2019 Dr. BERTRAND Joël This file is part of RPL/2. @@ -750,10 +750,17 @@ instruction_poke(struct_processus *s_eta // figure ! action.sa_handler = SIG_IGN; - action.sa_flags = SA_ONSTACK; + action.sa_flags = 0; + + if (pthread_mutex_lock(&mutex_sigaction) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } if (sigaction(SIGPIPE, &action, ®istre) != 0) { + pthread_mutex_unlock(&mutex_sigaction); pthread_mutex_unlock(&((*s_etat_processus) .mutex_pile_processus)); @@ -767,7 +774,7 @@ instruction_poke(struct_processus *s_eta if (envoi_signal_processus((*(*((struct_processus_fils *) (*(*l_element_courant).donnee).objet)) - .thread).pid, rpl_siginject) != 0) + .thread).pid, rpl_siginject, d_faux) != 0) { // Le processus fils peut s'être terminé. break; @@ -785,12 +792,14 @@ instruction_poke(struct_processus *s_eta if ((*s_etat_processus).erreur_systeme != d_es) { + pthread_mutex_unlock(&mutex_sigaction); pthread_mutex_unlock(&((*s_etat_processus) .mutex_pile_processus)); return; } } + /* # ifndef SEMAPHORES_NOMMES if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) @@ -798,9 +807,11 @@ instruction_poke(struct_processus *s_eta if (sem_post((*s_etat_processus).semaphore_fork) != 0) # endif { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_processus; return; } + */ while((longueur_ecriture = write_atomic(s_etat_processus, (*(*((struct_processus_fils *) @@ -808,6 +819,7 @@ instruction_poke(struct_processus *s_eta .pipe_nombre_injections[1], "-", sizeof(unsigned char))) != sizeof(unsigned char)) { + /* # ifndef SEMAPHORES_NOMMES while(sem_wait( &((*s_etat_processus).semaphore_fork)) != 0) @@ -823,9 +835,11 @@ instruction_poke(struct_processus *s_eta return; } } + */ if (longueur_ecriture == -1) { + pthread_mutex_unlock(&mutex_sigaction); pthread_mutex_unlock(&((*s_etat_processus) .mutex_pile_processus)); @@ -854,6 +868,7 @@ instruction_poke(struct_processus *s_eta if (sigaction(SIGPIPE, ®istre, NULL) != 0) { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_signal; return; @@ -862,6 +877,7 @@ instruction_poke(struct_processus *s_eta return; } + /* # ifndef SEMAPHORES_NOMMES if (sem_post( &((*s_etat_processus).semaphore_fork)) != 0) @@ -873,6 +889,7 @@ instruction_poke(struct_processus *s_eta (*s_etat_processus).erreur_systeme = d_es_processus; return; } + */ } if (ecriture_pipe(s_etat_processus, @@ -889,6 +906,7 @@ instruction_poke(struct_processus *s_eta } } + /* # ifndef SEMAPHORES_NOMMES while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) @@ -902,6 +920,7 @@ instruction_poke(struct_processus *s_eta return; } } + */ if (registre_stop == 0) { @@ -923,6 +942,7 @@ instruction_poke(struct_processus *s_eta if (sigaction(SIGPIPE, ®istre, NULL) != 0) { + pthread_mutex_unlock(&mutex_sigaction); pthread_mutex_unlock(&((*s_etat_processus) .mutex_pile_processus)); @@ -930,6 +950,12 @@ instruction_poke(struct_processus *s_eta return; } + if (pthread_mutex_unlock(&mutex_sigaction) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + break; } } @@ -956,11 +982,18 @@ instruction_poke(struct_processus *s_eta // de lecteur et on peut se prendre un SIGPIPE dans la // figure ! + if (pthread_mutex_lock(&mutex_sigaction) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + action.sa_handler = SIG_IGN; - action.sa_flags = SA_ONSTACK; + action.sa_flags = 0; if (sigaction(SIGPIPE, &action, ®istre) != 0) { + pthread_mutex_unlock(&mutex_sigaction); pthread_mutex_unlock(&((*s_etat_processus) .mutex_pile_processus)); @@ -976,6 +1009,7 @@ instruction_poke(struct_processus *s_eta (*(*l_element_courant).donnee).objet)).thread) .mutex)) != 0) { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_processus; return; } @@ -984,7 +1018,8 @@ instruction_poke(struct_processus *s_eta (*(*l_element_courant).donnee).objet)).thread) .thread_actif == d_vrai) { - if (envoi_signal_thread((*(*((struct_processus_fils *) + if (envoi_signal_thread(s_etat_processus, + (*(*((struct_processus_fils *) (*(*l_element_courant).donnee).objet)).thread) .tid, rpl_siginject) != 0) { @@ -995,6 +1030,7 @@ instruction_poke(struct_processus *s_eta (*(*l_element_courant).donnee).objet)) .thread).mutex)) != 0) { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -1010,6 +1046,7 @@ instruction_poke(struct_processus *s_eta (*(*l_element_courant).donnee).objet)) .thread).mutex)) != 0) { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_processus; return; } @@ -1021,6 +1058,7 @@ instruction_poke(struct_processus *s_eta (*(*l_element_courant).donnee).objet)).thread) .mutex)) != 0) { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_processus; return; } @@ -1037,12 +1075,14 @@ instruction_poke(struct_processus *s_eta if ((*s_etat_processus).erreur_systeme != d_es) { + pthread_mutex_unlock(&mutex_sigaction); pthread_mutex_unlock(&((*s_etat_processus) .mutex_pile_processus)); return; } } + /* # ifndef SEMAPHORES_NOMMES if (sem_post( &((*s_etat_processus).semaphore_fork)) != 0) @@ -1054,6 +1094,7 @@ instruction_poke(struct_processus *s_eta (*s_etat_processus).erreur_systeme = d_es_processus; return; } + */ while((longueur_ecriture = write_atomic(s_etat_processus, (*(*((struct_processus_fils *) @@ -1061,6 +1102,7 @@ instruction_poke(struct_processus *s_eta .pipe_nombre_injections[1], "-", sizeof(unsigned char))) != sizeof(unsigned char)) { + /* # ifndef SEMAPHORES_NOMMES while(sem_wait( &((*s_etat_processus).semaphore_fork)) != 0) @@ -1076,6 +1118,7 @@ instruction_poke(struct_processus *s_eta return; } } + */ if (longueur_ecriture == -1) { @@ -1107,14 +1150,17 @@ instruction_poke(struct_processus *s_eta if (sigaction(SIGPIPE, ®istre, NULL) != 0) { + pthread_mutex_unlock(&mutex_sigaction); (*s_etat_processus).erreur_systeme = d_es_signal; return; } + pthread_mutex_unlock(&mutex_sigaction); return; } + /* # ifndef SEMAPHORES_NOMMES if (sem_post( &((*s_etat_processus).semaphore_fork)) != 0) @@ -1126,6 +1172,7 @@ instruction_poke(struct_processus *s_eta (*s_etat_processus).erreur_systeme = d_es_processus; return; } + */ } if (ecriture_pipe(s_etat_processus, @@ -1142,6 +1189,7 @@ instruction_poke(struct_processus *s_eta } } + /* # ifndef SEMAPHORES_NOMMES while(sem_wait( &((*s_etat_processus).semaphore_fork)) != 0) @@ -1156,6 +1204,7 @@ instruction_poke(struct_processus *s_eta return; } } + */ if (registre_stop == 0) { @@ -1177,6 +1226,7 @@ instruction_poke(struct_processus *s_eta if (sigaction(SIGPIPE, ®istre, NULL) != 0) { + pthread_mutex_unlock(&mutex_sigaction); pthread_mutex_unlock(&((*s_etat_processus) .mutex_pile_processus)); @@ -1184,6 +1234,12 @@ instruction_poke(struct_processus *s_eta return; } + if (pthread_mutex_unlock(&mutex_sigaction) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_processus; + return; + } + break; } }