--- rpl/src/rpl.c 2015/02/01 09:47:19 1.167 +++ rpl/src/rpl.c 2017/07/02 22:28:20 1.194 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.20 - Copyright (C) 1989-2015 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.27 + Copyright (C) 1989-2017 Dr. BERTRAND Joël This file is part of RPL/2. @@ -123,8 +123,13 @@ rplinit(int argc, char *argv[], char *en errno = 0; s_queue_signaux = NULL; routine_recursive = 0; + nombre_thread_surveillance_processus = 0; pid_processus_pere = getpid(); +# ifdef DEBUG_PROC + __proc = 0; +# endif + # ifdef DEBUG_MEMOIRE debug_memoire_initialisation(); # endif @@ -299,6 +304,11 @@ rplinit(int argc, char *argv[], char *en pthread_mutex_init(&mutex_liste_variables_partagees, &attributs_mutex); pthread_mutexattr_destroy(&attributs_mutex); + pthread_mutexattr_init(&attributs_mutex); + pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&mutex_liste_threads, &attributs_mutex); + pthread_mutexattr_destroy(&attributs_mutex); + # ifndef SEMAPHORES_NOMMES sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); # else @@ -435,11 +445,11 @@ rplinit(int argc, char *argv[], char *en if ((*s_etat_processus).langue == 'F') { - printf("+++Copyright (C) 1989 à 2014, 2015 BERTRAND Joël\n"); + printf("+++Copyright (C) 1989 à 2016, 2017 BERTRAND Joël\n"); } else { - printf("+++Copyright (C) 1989 to 2014, 2015 BERTRAND Joel\n"); + printf("+++Copyright (C) 1989 to 2016, 2017 BERTRAND Joel\n"); } } @@ -509,39 +519,6 @@ rplinit(int argc, char *argv[], char *en } # endif - if (lancement_thread_signaux(s_etat_processus) != d_absence_erreur) - { -# 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 - - liberation_contexte_cas(s_etat_processus); - destruction_queue_signaux(s_etat_processus); - -# ifdef HAVE_STACK_OVERFLOW_RECOVERY - stackoverflow_deinstall_handler(); -# endif - - erreur = d_es_signal; - - if ((*s_etat_processus).langue == 'F') - { - printf("+++Système : Initialisation des signaux POSIX " - "impossible\n"); - } - else - { - printf("+++System : Initialization of POSIX signals failed\n"); - } - - return(EXIT_FAILURE); - } - action.sa_handler = interruption1; action.sa_flags = 0; @@ -699,7 +676,7 @@ rplinit(int argc, char *argv[], char *en return(EXIT_FAILURE); } - if (sigaction(SIGALRM, &action, NULL) != 0) + if (sigaction(SIGUSR2, &action, NULL) != 0) { # ifndef SEMAPHORES_NOMMES sem_post(&((*s_etat_processus).semaphore_fork)); @@ -733,7 +710,7 @@ rplinit(int argc, char *argv[], char *en } signal_test = SIGTEST; - raise(SIGALRM); + raise(SIGUSR2); attente.tv_sec = 0; attente.tv_nsec = 1000000; @@ -743,7 +720,7 @@ rplinit(int argc, char *argv[], char *en nanosleep(&attente, NULL); } - if (signal_test != SIGALRM) + if (signal_test != SIGUSR2) { # ifndef SEMAPHORES_NOMMES sem_post(&((*s_etat_processus).semaphore_fork)); @@ -4985,7 +4962,7 @@ rplinit(int argc, char *argv[], char *en (*(*((struct_processus_fils *) (*(*((struct_liste_chainee *) l_element_courant)).donnee).objet)) - .thread).pid, rpl_sigurg); + .thread).pid, rpl_sigurg, d_faux); } else { @@ -4996,7 +4973,7 @@ rplinit(int argc, char *argv[], char *en (*(*((struct_processus_fils *) (*(*((struct_liste_chainee *) l_element_courant)).donnee).objet)) - .thread).pid, rpl_sigabort); + .thread).pid, rpl_sigabort, d_faux); } else { @@ -5004,7 +4981,7 @@ rplinit(int argc, char *argv[], char *en (*(*((struct_processus_fils *) (*(*((struct_liste_chainee *) l_element_courant)).donnee).objet)) - .thread).pid, rpl_sigstop); + .thread).pid, rpl_sigstop, d_faux); } } } @@ -5401,9 +5378,9 @@ rplinit(int argc, char *argv[], char *en { if ((*resultats) != NULL) { - free((*resultats)); + sys_free((*resultats)); - if (((*resultats) = malloc(((size_t) + if (((*resultats) = sys_malloc(((size_t) ((*s_etat_processus) .hauteur_pile_operationnelle + 1)) * sizeof(unsigned char **))) != NULL) @@ -5724,6 +5701,15 @@ rplinit(int argc, char *argv[], char *en retrait_thread(s_etat_processus); + attente.tv_sec = 0; + attente.tv_nsec = GRANULARITE_us * 1000; + + while(nombre_thread_surveillance_processus != 0) + { + nanosleep(&attente, NULL); + INCR_GRANULARITE(attente.tv_nsec); + } + pthread_mutex_destroy(&((*s_etat_processus).mutex_pile_processus)); pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation)); pthread_mutex_destroy(&((*s_etat_processus).mutex_interruptions)); @@ -5757,12 +5743,13 @@ rplinit(int argc, char *argv[], char *en erreur = d_erreur; } - sys_free(arg_exec); - arret_thread_signaux(s_etat_processus); liberation_etat_processus_readline(); + liberation_allocateur_buffer(s_etat_processus); pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation_buffer)); + sys_free(s_etat_processus); + sys_free(arg_exec); # ifdef DEBUG_MEMOIRE debug_memoire_verification(); @@ -5801,6 +5788,8 @@ informations(struct_processus *s_etat_pr printf(" -i : fonctionnement interactif\n"); printf(" -l : licence d'utilisation\n"); printf(" -n : ignorance du signal HUP\n"); + printf(" -m : chargement d'un module RPL/SO avant la " + "compilation\n"); printf(" -p : précompilation du script avant exécution\n"); printf(" -P : profilage (-P ou -PP)\n"); printf(" -s : empêchement de l'ouverture de l'écran initial\n"); @@ -5822,6 +5811,7 @@ informations(struct_processus *s_etat_pr printf(" -i : runs the RPL/2 sequencer in interactive mode\n"); printf(" -l : prints the user licence of the software\n"); printf(" -n : ignores HUP signal\n"); + printf(" -m : loads RPL/SO object before compilation\n"); printf(" -p : precompiles script\n"); printf(" -P : computes profile data (-P or -PP)\n"); printf(" -s : disables splash screen\n");