--- rpl/src/rpl.c 2011/09/20 08:56:24 1.90 +++ rpl/src/rpl.c 2011/09/20 19:28:39 1.93 @@ -112,7 +112,7 @@ rplinit(int argc, char *argv[], unsigned # ifndef SEMAPHORES_NOMMES sem_init(&semaphore_gestionnaires_signaux, 0, 0); # else - semaphore_gestionnaires_signaux = sem_init2(0, getpid()); + semaphore_gestionnaires_signaux = sem_init2(0, getpid(), SEM_SIGNAUX); if (semaphore_gestionnaires_signaux == SEM_FAILED) { @@ -191,7 +191,24 @@ rplinit(int argc, char *argv[], unsigned &attributs_mutex); pthread_mutexattr_destroy(&attributs_mutex); - sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); +# ifndef SEMAPHORES_NOMMES + sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); +# else + if (((*s_etat_processus).semaphore_fork = sem_init3(0, getpid(), + pthread_self(), SEM_FORK)) == SEM_FAILED) + { + if ((*s_etat_processus).langue == 'F') + { + uprintf("+++Système : Mémoire insuffisante\n"); + } + else + { + uprintf("+++System : Not enough memory\n"); + } + + return(EXIT_FAILURE); + } +# endif pthread_mutexattr_init(&attributs_mutex); pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); @@ -3469,8 +3486,14 @@ rplinit(int argc, char *argv[], unsigned pthread_mutex_destroy(&((*s_etat_processus).mutex)); pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation)); +# ifndef SEMAPHORES_NOMMES sem_post(&((*s_etat_processus).semaphore_fork)); sem_destroy(&((*s_etat_processus).semaphore_fork)); +# else + sem_post((*s_etat_processus).semaphore_fork); + sem_destroy3((*s_etat_processus).semaphore_fork, getpid(), pthread_self(), + SEM_FORK); +# endif free((*s_etat_processus).localisation); @@ -3482,7 +3505,7 @@ rplinit(int argc, char *argv[], unsigned sem_destroy(&semaphore_gestionnaires_signaux); # else sem_post(semaphore_gestionnaires_signaux); - sem_destroy2(semaphore_gestionnaires_signaux, getpid()); + sem_destroy2(semaphore_gestionnaires_signaux, getpid(), SEM_SIGNAUX); # endif destruction_queue_signaux(s_etat_processus);