--- rpl/src/rpl.c 2011/04/14 08:46:50 1.58.2.3 +++ rpl/src/rpl.c 2014/07/17 08:07:26 1.159 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.0.23 - Copyright (C) 1989-2011 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.19 + Copyright (C) 1989-2014 Dr. BERTRAND Joël This file is part of RPL/2. @@ -23,11 +23,9 @@ #define MAIN_RPL #include "rpl-conv.h" -#ifdef IPCS_SYSV -#ifndef OS2 - unsigned char *chemin_semaphores_SysV; -#endif -#endif +// Bug de gcc à partir de gcc 4.6 (bug 48544) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclobbered" /* @@ -37,16 +35,27 @@ */ int -rplinit(int argc, char *argv[], unsigned char ***resultats, char *rpl_home) +rplinit(int argc, char *argv[], char *envp[], + unsigned char ***resultats, char *rpl_home) { # include "copyright-conv.h" # include "licence-conv.h" + char **arg_exec; + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + char pile_signaux[SIGSTKSZ]; +# endif + +# define RPL_PATH_MAX 1024 + char repertoire_initial[RPL_PATH_MAX]; + file *f_source; int erreur_historique; int option_P; - int status; + + integer8 i; logical1 core; logical1 debug; @@ -77,7 +86,14 @@ rplinit(int argc, char *argv[], unsigned struct_processus *s_etat_processus; - struct_table_variables_partagees s_variables_partagees; + struct_liste_variables_partagees *l_element_partage_courant; + struct_liste_variables_partagees *l_element_partage_suivant; + + struct_liste_variables_statiques *l_element_statique_courant; + struct_liste_variables_statiques *l_element_statique_suivant; + + struct_arbre_variables_partagees *s_arbre_variables_partagees; + struct_liste_variables_partagees *l_liste_variables_partagees; struct sigaction action; struct sigaction registre; @@ -96,7 +112,6 @@ rplinit(int argc, char *argv[], unsigned unsigned char *ptr; unsigned char *tampon; - unsigned long i; unsigned long unite_fichier; void *l_element_courant; @@ -106,10 +121,9 @@ rplinit(int argc, char *argv[], unsigned volatile unsigned char traitement_fichier_temporaire; errno = 0; - -# ifdef DMALLOC - atexit(dmalloc_shutdown()); -# endif + s_queue_signaux = NULL; + routine_recursive = 0; + pid_processus_pere = getpid(); # ifdef DEBUG_MEMOIRE debug_memoire_initialisation(); @@ -118,19 +132,7 @@ rplinit(int argc, char *argv[], unsigned setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(stderr, NULL, _IOLBF, 0); -# ifndef SEMAPHORES_NOMMES - sem_init(&semaphore_liste_threads, 0, 1); - sem_init(&semaphore_gestionnaires_signaux, 0, 0); - sem_init(&semaphore_gestionnaires_signaux_atomique, 0, 1); -# else - semaphore_liste_threads = sem_init2(1, sem_liste_threads); - semaphore_gestionnaires_signaux = sem_init2(0, sem_gestionnaires_signaux); - semaphore_gestionnaires_signaux_atomique = sem_init2(1, - sem_gestionnaires_signaux_atomique); - - if ((semaphore_liste_threads == SEM_FAILED) || - (semaphore_gestionnaires_signaux == SEM_FAILED) || - (semaphore_gestionnaires_signaux_atomique == SEM_FAILED)) + if ((s_etat_processus = malloc(sizeof(struct_processus))) == NULL) { erreur = d_es_allocation_memoire; @@ -152,22 +154,22 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } -# endif - if ((s_etat_processus = malloc(sizeof(struct_processus))) == NULL) + if ((langue = getenv("LANG")) != NULL) { - erreur = d_es_allocation_memoire; + (*s_etat_processus).langue = (strncmp(langue, "fr", 2) == 0) + ? 'F' : 'E'; + } + else + { + (*s_etat_processus).langue = 'E'; + } - if ((langue = getenv("LANG")) != NULL) + if (getcwd(repertoire_initial, RPL_PATH_MAX) == NULL) + { + if ((*s_etat_processus).langue == 'F') { - if (strncmp(langue, "fr", 2) == 0) - { - uprintf("+++Système : Mémoire insuffisante\n"); - } - else - { - uprintf("+++System : Not enough memory\n"); - } + uprintf("+++Système : Mémoire insuffisante\n"); } else { @@ -177,25 +179,52 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } - if ((langue = getenv("LANG")) != NULL) + if ((arg_exec = malloc((((size_t) argc) + 1) * sizeof(char *))) == NULL) { - (*s_etat_processus).langue = (strncmp(langue, "fr", 2) == 0) - ? 'F' : 'E'; + if ((*s_etat_processus).langue == 'F') + { + uprintf("+++Système : Mémoire insuffisante\n"); + } + else + { + uprintf("+++System : Not enough memory\n"); + } + + return(EXIT_FAILURE); } - else + + for(i = 0; i < argc; i++) { - (*s_etat_processus).langue = 'E'; + arg_exec[i] = argv[i]; } + argv[argc] = NULL; + + initialisation_contexte_cas(s_etat_processus); + (*s_etat_processus).exception = d_ep; (*s_etat_processus).erreur_systeme = d_es; (*s_etat_processus).erreur_execution = d_ex; + (*s_etat_processus).requete_redemarrage = d_faux; (*s_etat_processus).rpl_home = rpl_home; pthread_mutexattr_init(&attributs_mutex); pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); - pthread_mutex_init(&((*s_etat_processus).mutex), &attributs_mutex); + pthread_mutex_init(&((*s_etat_processus).mutex_pile_processus), + &attributs_mutex); + pthread_mutexattr_destroy(&attributs_mutex); + + pthread_mutexattr_init(&attributs_mutex); + pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); + pthread_mutex_init(&((*s_etat_processus).mutex_interruptions), + &attributs_mutex); + pthread_mutexattr_destroy(&attributs_mutex); + + pthread_mutexattr_init(&attributs_mutex); + pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); + pthread_mutex_init(&((*s_etat_processus).mutex_signaux), + &attributs_mutex); pthread_mutexattr_destroy(&attributs_mutex); pthread_mutexattr_init(&attributs_mutex); @@ -204,23 +233,35 @@ rplinit(int argc, char *argv[], unsigned &attributs_mutex); pthread_mutexattr_destroy(&attributs_mutex); + pthread_mutexattr_init(&attributs_mutex); + pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&mutex_sections_critiques, &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_variables_partagees, &attributs_mutex); + pthread_mutexattr_destroy(&attributs_mutex); + # ifndef SEMAPHORES_NOMMES - sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); + sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); # else - if (((*s_etat_processus).semaphore_fork = sem_init2(0, sem_fork)) == - SEM_FAILED) - { - if ((*s_etat_processus).langue == 'F') - { - uprintf("+++Système : Mémoire insuffisante\n"); - } - else + if (((*s_etat_processus).semaphore_fork = sem_init3(0, getpid(), + pthread_self(), SEM_FORK)) == SEM_FAILED) { - uprintf("+++System : Not enough memory\n"); - } + liberation_contexte_cas(s_etat_processus); - return(EXIT_FAILURE); - } + 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); @@ -229,45 +270,58 @@ rplinit(int argc, char *argv[], unsigned &attributs_mutex); pthread_mutexattr_destroy(&attributs_mutex); - (*s_etat_processus).s_liste_variables_partagees = &s_variables_partagees; - - s_variables_partagees.nombre_variables = 0; - s_variables_partagees.nombre_variables_allouees = 0; - s_variables_partagees.table = NULL; - - pthread_mutexattr_init(&attributs_mutex); - pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); - pthread_mutex_init(&((*((*s_etat_processus).s_liste_variables_partagees)) - .mutex), &attributs_mutex); - pthread_mutexattr_destroy(&attributs_mutex); - (*s_etat_processus).chemin_fichiers_temporaires = recherche_chemin_fichiers_temporaires(s_etat_processus); -# ifdef IPCS_SYSV -# ifndef OS2 - chemin_semaphores_SysV = (*s_etat_processus).chemin_fichiers_temporaires; -# endif -# endif - -# ifdef _BROKEN_SIGINFO - creation_fifos_signaux(s_etat_processus); -# ifdef return -# undef return -# endif -# define return destruction_fifos_signaux(s_etat_processus); return -# endif - insertion_thread(s_etat_processus, d_vrai); + creation_queue_signaux(s_etat_processus); -# ifndef OS2 - localisation_courante(s_etat_processus); -# else if ((*s_etat_processus).erreur_systeme != d_es) { - if (((*s_etat_processus).localisation = malloc((strlen(d_locale) + 1) * - sizeof(unsigned char))) == NULL) +# 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); + + if ((*s_etat_processus).langue == 'F') { + uprintf("+++Système : Mémoire insuffisante\n"); + } + else + { + uprintf("+++System : Not enough memory\n"); + } + + return(EXIT_FAILURE); + } + + if (d_forced_locale == 0) + { + localisation_courante(s_etat_processus); + } + else + { + if (((*s_etat_processus).localisation = malloc((strlen(d_locale) + + 1) * sizeof(unsigned char))) == NULL) + { +# 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); + liberation_queue_signaux(s_etat_processus); + if ((*s_etat_processus).langue == 'F') { uprintf("+++Système : Mémoire insuffisante\n"); @@ -282,7 +336,6 @@ rplinit(int argc, char *argv[], unsigned strcpy((*s_etat_processus).localisation, d_locale); } -# endif (*s_etat_processus).erreur_systeme = d_es; @@ -291,6 +344,18 @@ rplinit(int argc, char *argv[], unsigned if (((*s_etat_processus).localisation = malloc((strlen(d_locale) + 1) * sizeof(unsigned char))) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + if ((*s_etat_processus).langue == 'F') { uprintf("+++Système : Mémoire insuffisante\n"); @@ -306,16 +371,20 @@ rplinit(int argc, char *argv[], unsigned strcpy((*s_etat_processus).localisation, d_locale); } - printf("+++RPL/2 (R) version %s (%s)\n", d_version_rpl, - ((*s_etat_processus).langue == 'F') ? d_date_rpl : d_date_en_rpl); - - if ((*s_etat_processus).langue == 'F') + if (resultats == NULL) // Appel direct { - printf("+++Copyright (C) 1989 à 2010, 2011 BERTRAND Joël\n"); - } - else - { - printf("+++Copyright (C) 1989 to 2010, 2011 BERTRAND Joel\n"); + printf("+++RPL/2 (R) version %s (%s)\n", d_version_rpl, + ((*s_etat_processus).langue == 'F') + ? d_date_rpl : d_date_en_rpl); + + if ((*s_etat_processus).langue == 'F') + { + printf("+++Copyright (C) 1989 à 2013, 2014 BERTRAND Joël\n"); + } + else + { + printf("+++Copyright (C) 1989 to 2013, 2014 BERTRAND Joel\n"); + } } if (getenv("HOME") != NULL) @@ -340,93 +409,104 @@ rplinit(int argc, char *argv[], unsigned home = ""; } - // Initialisation d'une clef +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + if (stackoverflow_install_handler(interruption_depassement_pile, + pile_signaux, sizeof(pile_signaux)) != 0) + { +# 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 - if (pthread_key_create(&semaphore_fork_processus_courant, NULL) != 0) - { - if ((*s_etat_processus).langue == 'F') - { - printf("+++Système : Mémoire insuffisante\n"); - } - else - { - printf("+++System : Not enough memory\n"); - } + liberation_contexte_cas(s_etat_processus); + liberation_queue_signaux(s_etat_processus); - return(EXIT_FAILURE); - } + erreur = d_es_signal; -# ifndef SEMAPHORES_NOMMES - if (pthread_setspecific(semaphore_fork_processus_courant, - &((*s_etat_processus).semaphore_fork)) != 0) + if ((*s_etat_processus).langue == 'F') + { + printf("+++Système : Initialisation de la pile alternative " + "impossible\n"); + } + else + { + printf("+++System : Initialization of alternate " + "stack failed\n"); + } + + return(EXIT_FAILURE); + } # else - if (pthread_setspecific(semaphore_fork_processus_courant, - (*s_etat_processus).semaphore_fork) != 0) -# endif - { if ((*s_etat_processus).langue == 'F') { - printf("+++Système : Mémoire insuffisante\n"); + printf("+++Attention : Le système ne supporte pas de pile " + "alternative\n"); } else { - printf("+++System : Not enough memory\n"); + printf("+++Warning : Operating system does not support alternate " + "stack\n"); } +# endif - return(EXIT_FAILURE); - } - - // Initialisation d'une pile de signal pour récupérer les - // débordement de pile - -# if !defined(Cygwin) && !defined(OpenBSD) - if (((*s_etat_processus).pile_signal.ss_sp = - malloc((*s_etat_processus).pile_signal.ss_size = - SIGSTKSZ)) == NULL) + if (lancement_thread_signaux(s_etat_processus) != d_absence_erreur) { - erreur = d_es_allocation_memoire; +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif - if ((*s_etat_processus).langue == 'F') - { - printf("+++Système : Mémoire insuffisante\n"); - } - else - { - printf("+++System : Not enough memory\n"); - } - - return(EXIT_FAILURE); - } - - (*s_etat_processus).pile_signal.ss_flags = 0; - - if (sigaltstack(&((*s_etat_processus).pile_signal), NULL) != 0) - { erreur = d_es_signal; if ((*s_etat_processus).langue == 'F') { - printf("+++Système : Initialisation de la pile spécifique de signal" - " impossible\n"); + printf("+++Système : Initialisation des signaux POSIX " + "impossible\n"); } else { - printf("+++System : Initialization of signal stack failed\n"); + printf("+++System : Initialization of POSIX signals failed\n"); } return(EXIT_FAILURE); } -# endif -# ifndef _BROKEN_SIGINFO - action.sa_sigaction = interruption1; -# else action.sa_handler = interruption1; -# endif - action.sa_flags = SA_ONSTACK | SA_SIGINFO; + action.sa_flags = 0; if (sigaction(SIGINT, &action, NULL) != 0) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + erreur = d_es_signal; if ((*s_etat_processus).langue == 'F') @@ -442,8 +522,35 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } - if (sigaction(SIGTERM, &action, NULL) != 0) + signal_test = SIGTEST; + raise(SIGINT); + + attente.tv_sec = 0; + attente.tv_nsec = 1000000; + + for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++) { + nanosleep(&attente, NULL); + } + + if (signal_test != SIGINT) + { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + erreur = d_es_signal; if ((*s_etat_processus).langue == 'F') @@ -459,15 +566,26 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } -# ifndef _BROKEN_SIGINFO - action.sa_sigaction = interruption2; -# else - action.sa_handler = interruption2; -# endif - action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; - - if (sigaction(SIGTSTP, &action, NULL) != 0) + if (sigaction(SIGTERM, &action, NULL) != 0) { +# 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); + liberation_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 " @@ -481,16 +599,37 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } -# ifndef _BROKEN_SIGINFO - action.sa_sigaction = interruption4; -# else - action.sa_handler = interruption4; -# endif - // SIGCONT ne doit pas pouvoir être appelé depuis son gestionnaire. - action.sa_flags = SA_ONSTACK | SA_SIGINFO; + signal_test = SIGTEST; + raise(SIGTERM); - if (sigaction(SIGSTART, &action, NULL) != 0) + attente.tv_sec = 0; + attente.tv_nsec = 1000000; + + for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++) { + nanosleep(&attente, NULL); + } + + if (signal_test != SIGTERM) + { +# 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); + liberation_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 " @@ -504,8 +643,26 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } - if (sigaction(SIGCONT, &action, NULL) != 0) + if (sigaction(SIGALRM, &action, NULL) != 0) { +# 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); + liberation_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 " @@ -519,15 +676,35 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } -# ifndef _BROKEN_SIGINFO - action.sa_sigaction = interruption5; -# else - action.sa_handler = interruption5; -# endif - action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; + signal_test = SIGTEST; + raise(SIGALRM); + + attente.tv_sec = 0; + attente.tv_nsec = 1000000; + + for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++) + { + nanosleep(&attente, NULL); + } - if (sigaction(SIGFSTOP, &action, NULL) != 0) + if (signal_test != SIGALRM) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + erreur = d_es_signal; if ((*s_etat_processus).langue == 'F') @@ -543,16 +720,26 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } -# ifndef _BROKEN_SIGINFO - action.sa_sigaction = interruption11; -# else - action.sa_handler = interruption11; -# endif - action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; + action.sa_handler = interruption2; + action.sa_flags = 0; - if (sigaction(SIGFABORT, &action, NULL) != 0) + if (sigaction(SIGTSTP, &action, NULL) != 0) { - erreur = d_es_signal; +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif if ((*s_etat_processus).langue == 'F') { @@ -567,15 +754,35 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } -# ifndef _BROKEN_SIGINFO - action.sa_sigaction = interruption8; -# else - action.sa_handler = interruption8; -# endif - action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; + signal_test = SIGTEST; + raise(SIGTSTP); + + attente.tv_sec = 0; + attente.tv_nsec = 1000000; + + for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++) + { + nanosleep(&attente, NULL); + } - if (sigaction(SIGURG, &action, NULL) != 0) + if (signal_test != SIGTSTP) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + erreur = d_es_signal; if ((*s_etat_processus).langue == 'F') @@ -591,15 +798,27 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } -# ifndef _BROKEN_SIGINFO - action.sa_sigaction = interruption7; -# else - action.sa_handler = interruption7; -# endif - action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; + action.sa_handler = interruption5; + action.sa_flags = 0; if (sigaction(SIGPIPE, &action, NULL) != 0) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + erreur = d_es_signal; if ((*s_etat_processus).langue == 'F') @@ -615,15 +834,35 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } -# ifndef _BROKEN_SIGINFO - action.sa_sigaction = interruption6; -# else - action.sa_handler = interruption6; -# endif - action.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_NODEFER; + signal_test = SIGTEST; + raise(SIGPIPE); + + attente.tv_sec = 0; + attente.tv_nsec = 1000000; - if (sigaction(SIGINJECT, &action, NULL) != 0) + for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++) { + nanosleep(&attente, NULL); + } + + if (signal_test != SIGPIPE) + { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + erreur = d_es_signal; if ((*s_etat_processus).langue == 'F') @@ -639,15 +878,27 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } -# ifndef _BROKEN_SIGINFO - action.sa_sigaction = interruption9; -# else - action.sa_handler = interruption9; -# endif - action.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_NODEFER; + action.sa_handler = interruption1; + action.sa_flags = 0; - if (sigaction(SIGABORT, &action, NULL) != 0) + if (sigaction(SIGUSR1, &action, NULL) != 0) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + erreur = d_es_signal; if ((*s_etat_processus).langue == 'F') @@ -663,15 +914,35 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } -# ifndef _BROKEN_SIGINFO - action.sa_sigaction = interruption1; -# else - action.sa_handler = interruption1; -# endif - action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; + signal_test = SIGTEST; + raise(SIGUSR1); - if (sigaction(SIGALRM, &action, NULL) != 0) + attente.tv_sec = 0; + attente.tv_nsec = 1000000; + + for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++) + { + nanosleep(&attente, NULL); + } + + if (signal_test != SIGUSR1) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + erreur = d_es_signal; if ((*s_etat_processus).langue == 'F') @@ -687,12 +958,7 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } -# ifndef _BROKEN_SIGINFO - action.sa_sigaction = interruption3; -# else - action.sa_handler = interruption3; -# endif - action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; + signal_test = SIGTEST + 1; erreur = d_absence_erreur; core = d_faux; @@ -740,6 +1006,15 @@ rplinit(int argc, char *argv[], unsigned option_t = d_faux; option_v = d_faux; + // Lorsque le programme est appelé depuis un shebang, argv[0] contient + // le chemin du programme et argv[1] tous les arguments. + // argv[2] contient quant à lui le nom du script RPL/2. + // + // Exemple : + // argv[0] : /usr/local/bin/rpl + // argv[1] : -csdp -t 800 + // argv[2] : ./on_exit.rpl + while((--argc) > 0) { if ((*(++argv))[0] == '-') @@ -752,6 +1027,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_a == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -a présente " @@ -774,6 +1066,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_A == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -A présente " @@ -798,6 +1107,26 @@ rplinit(int argc, char *argv[], unsigned if ((arguments = malloc((strlen(argv[0]) + 7) * sizeof(unsigned char))) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Mémoire " @@ -834,6 +1163,26 @@ rplinit(int argc, char *argv[], unsigned if ((arguments = malloc((strlen(argv[0]) + 7) * sizeof(unsigned char))) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Mémoire " @@ -865,6 +1214,23 @@ rplinit(int argc, char *argv[], unsigned } else { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : Aucune donnée " @@ -886,6 +1252,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_c == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -c présente " @@ -909,6 +1292,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_d == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -d présente " @@ -932,6 +1332,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_D == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -D présente " @@ -954,6 +1371,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_h == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -h présente " @@ -977,6 +1411,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_i == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -i présente " @@ -992,6 +1443,23 @@ rplinit(int argc, char *argv[], unsigned } else if (option_S == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : options -i et -S " @@ -1007,6 +1475,23 @@ rplinit(int argc, char *argv[], unsigned } else if (option_p == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : options -i et -p " @@ -1031,6 +1516,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_l == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -l présente " @@ -1063,6 +1565,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_n == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -n présente " @@ -1086,6 +1605,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_p == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -p présente " @@ -1101,6 +1637,23 @@ rplinit(int argc, char *argv[], unsigned } else if (option_i == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : options -i et -p " @@ -1124,6 +1677,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_P > 2) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -P présente " @@ -1147,6 +1717,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_s == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -s présente " @@ -1170,6 +1757,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_S == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -S présente " @@ -1185,6 +1789,23 @@ rplinit(int argc, char *argv[], unsigned } else if (option_i == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : options -i et -S " @@ -1210,6 +1831,26 @@ rplinit(int argc, char *argv[], unsigned malloc((strlen(argv[0]) + 1) * sizeof(unsigned char))) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Mémoire " @@ -1244,6 +1885,26 @@ rplinit(int argc, char *argv[], unsigned malloc((strlen(argv[0]) + 1) * sizeof(unsigned char))) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Mémoire " @@ -1272,6 +1933,23 @@ rplinit(int argc, char *argv[], unsigned } else { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : Aucun script " @@ -1290,6 +1968,23 @@ rplinit(int argc, char *argv[], unsigned compactage((*s_etat_processus) .definitions_chainees)) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Mémoire " @@ -1305,7 +2000,7 @@ rplinit(int argc, char *argv[], unsigned } (*s_etat_processus).longueur_definitions_chainees = - strlen((*s_etat_processus) + (integer8) strlen((*s_etat_processus) .definitions_chainees); break; @@ -1315,6 +2010,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_t == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -t présente " @@ -1340,6 +2052,26 @@ rplinit(int argc, char *argv[], unsigned if ((type_debug = malloc((strlen(argv[0]) + 1) * sizeof(unsigned char))) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Mémoire " @@ -1374,6 +2106,26 @@ rplinit(int argc, char *argv[], unsigned malloc((strlen(argv[0]) + 1) * sizeof(unsigned char))) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Mémoire " @@ -1401,6 +2153,23 @@ rplinit(int argc, char *argv[], unsigned } else { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : Aucun niveau " @@ -1444,6 +2213,28 @@ rplinit(int argc, char *argv[], unsigned default: { +# 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); + liberation_queue_signaux( + s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : Niveau " @@ -1467,6 +2258,23 @@ rplinit(int argc, char *argv[], unsigned if (sscanf(type_debug, "%llX", &((*s_etat_processus).type_debug)) != 1) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : Niveau " @@ -1489,6 +2297,23 @@ rplinit(int argc, char *argv[], unsigned { if (option_v == d_vrai) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : option -v présente " @@ -1535,6 +2360,12 @@ rplinit(int argc, char *argv[], unsigned break; } + case '-': + case ' ': + { + break; + } + default : { if ((*s_etat_processus).langue == 'F') @@ -1579,10 +2410,72 @@ rplinit(int argc, char *argv[], unsigned } } + /* + * Dans le cas où le programme est appelé avec l'option -d, + * on ne récupère par les signaux de violation d'accès. On + * tente simplement la récupération des dépassements de pile. + */ + if (debug == d_faux) { +# ifdef HAVE_SIGSEGV_RECOVERY + if (sigsegv_install_handler(interruption_violation_access) != 0) + { +# 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); + liberation_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 de la pile alternative " + "impossible\n"); + } + else + { + printf("+++System : Initialization of alternate " + "stack failed\n"); + } + + return(EXIT_FAILURE); + } +# else + action.sa_handler = interruption3; + action.sa_flags = 0; + if (sigaction(SIGSEGV, &action, NULL) != 0) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Initialisation des signaux POSIX " @@ -1597,8 +2490,82 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } + signal_test = SIGTEST; + raise(SIGSEGV); + + attente.tv_sec = 0; + attente.tv_nsec = 1000000; + + for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++) + { + nanosleep(&attente, NULL); + } + + if (signal_test != SIGSEGV) + { +# 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); + liberation_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); + } +# endif + + action.sa_handler = interruption3; + action.sa_flags = 0; + if (sigaction(SIGBUS, &action, NULL) != 0) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Initialisation des signaux POSIX " @@ -1612,19 +2579,93 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } + + signal_test = SIGTEST; + raise(SIGBUS); + + attente.tv_sec = 0; + attente.tv_nsec = 1000000; + + for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++) + { + nanosleep(&attente, NULL); + } + + if (signal_test != SIGBUS) + { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_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); + } + } if (option_n == d_vrai) { -# ifndef _BROKEN_SIGINFO - action.sa_sigaction = interruption10; -# else - action.sa_handler = interruption10; -# endif - action.sa_flags = SA_ONSTACK | SA_SIGINFO; + action.sa_handler = interruption4; + action.sa_flags = 0; if (sigaction(SIGHUP, &action, NULL) != 0) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Initialisation des signaux POSIX " @@ -1667,6 +2708,30 @@ rplinit(int argc, char *argv[], unsigned creation_nom_fichier(s_etat_processus, (*s_etat_processus) .chemin_fichiers_temporaires)) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Fichier indisponible\n"); @@ -1682,6 +2747,30 @@ rplinit(int argc, char *argv[], unsigned if ((f_source = fopen(nom_fichier_temporaire, "w")) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Fichier introuvable\n"); @@ -1696,6 +2785,30 @@ rplinit(int argc, char *argv[], unsigned if (fprintf(f_source, "MODE_INTERACTIF\n") < 0) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Erreur d'écriture dans un fichier\n"); @@ -1711,6 +2824,30 @@ rplinit(int argc, char *argv[], unsigned if (fprintf(f_source, "<< DO HALT UNTIL FALSE END >>\n") < 0) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Erreur d'écriture dans un fichier\n"); @@ -1725,6 +2862,30 @@ rplinit(int argc, char *argv[], unsigned if (fclose(f_source) != 0) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Fichier indisponible\n"); @@ -1762,6 +2923,29 @@ rplinit(int argc, char *argv[], unsigned if (((existence == d_faux) || (erreur_fichier != d_absence_erreur)) && (option_S == d_faux)) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if (presence_definition == 'O') { if ((*s_etat_processus).langue == 'F') @@ -1794,6 +2978,29 @@ rplinit(int argc, char *argv[], unsigned if ((*s_etat_processus).chemin_fichiers_temporaires == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Chemin des fichiers temporaires nul\n"); @@ -1831,6 +3038,8 @@ rplinit(int argc, char *argv[], unsigned gettimeofday(&((*s_etat_processus).horodatage_profilage), NULL); (*s_etat_processus).liste_mutexes = NULL; + (*s_etat_processus).sections_critiques = 0; + (*s_etat_processus).initialisation_scheduler = d_faux; (*s_etat_processus).test_instruction = 'N'; (*s_etat_processus).nombre_arguments = 0; @@ -1862,19 +3071,23 @@ rplinit(int argc, char *argv[], unsigned (*s_etat_processus).l_base_pile = NULL; (*s_etat_processus).l_base_pile_last = NULL; - (*s_etat_processus).s_liste_variables = NULL; + (*s_etat_processus).s_arbre_variables = NULL; + (*s_etat_processus).l_liste_variables_par_niveau = NULL; + (*s_etat_processus).l_liste_variables_statiques = NULL; (*s_etat_processus).gel_liste_variables = d_faux; - (*s_etat_processus).nombre_variables = 0; - (*s_etat_processus).nombre_variables_allouees = 0; - (*s_etat_processus).s_liste_variables_statiques = NULL; - (*s_etat_processus).nombre_variables_statiques = 0; - (*s_etat_processus).nombre_variables_statiques_allouees = 0; + s_arbre_variables_partagees = NULL; + l_liste_variables_partagees = NULL; + (*s_etat_processus).s_arbre_variables_partagees = + &s_arbre_variables_partagees; + (*s_etat_processus).l_liste_variables_partagees = + &l_liste_variables_partagees; + (*s_etat_processus).pointeur_variable_courante = NULL; + (*s_etat_processus).pointeur_variable_statique_courante = NULL; + (*s_etat_processus).pointeur_variable_partagee_courante = NULL; (*s_etat_processus).niveau_courant = 0; (*s_etat_processus).niveau_initial = 0; (*s_etat_processus).creation_variables_statiques = d_faux; (*s_etat_processus).creation_variables_partagees = d_faux; - (*s_etat_processus).position_variable_courante = 0; - (*s_etat_processus).position_variable_statique_courante = 0; (*s_etat_processus).s_bibliotheques = NULL; (*s_etat_processus).s_instructions_externes = NULL; @@ -2003,6 +3216,7 @@ rplinit(int argc, char *argv[], unsigned (*s_etat_processus).arbre_instructions = NULL; (*s_etat_processus).tid_processus_pere = pthread_self(); + (*s_etat_processus).tid = pthread_self(); (*s_etat_processus).pid_processus_pere = getpid(); (*s_etat_processus).processus_detache = d_vrai; (*s_etat_processus).var_volatile_processus_pere = -1; @@ -2016,12 +3230,39 @@ rplinit(int argc, char *argv[], unsigned (*s_etat_processus).var_volatile_recursivite = 0; (*s_etat_processus).var_volatile_exception_gsl = 0; (*s_etat_processus).arret_depuis_abort = 0; + (*s_etat_processus).pointeur_signal_lecture = 0; + (*s_etat_processus).pointeur_signal_ecriture = 0; initialisation_allocateur(s_etat_processus); initialisation_drapeaux(s_etat_processus); + initialisation_variables(s_etat_processus); + initialisation_instructions(s_etat_processus); if ((*s_etat_processus).erreur_systeme != d_es) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Système : Mémoire insuffisante\n"); @@ -2037,6 +3278,29 @@ rplinit(int argc, char *argv[], unsigned if (((*s_etat_processus).instruction_derniere_erreur = malloc(sizeof(unsigned char))) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + erreur = d_es_allocation_memoire; if ((*s_etat_processus).langue == 'F') @@ -2066,6 +3330,29 @@ rplinit(int argc, char *argv[], unsigned if (((*s_etat_processus).instruction_courante = (unsigned char *) malloc(sizeof(unsigned char))) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + erreur = d_es_allocation_memoire; if ((*s_etat_processus).langue == 'F') @@ -2095,12 +3382,10 @@ rplinit(int argc, char *argv[], unsigned (*((*s_etat_processus).l_base_pile_systeme)) .retour_definition = 'Y'; - (*s_etat_processus).indep = (struct_objet *) malloc( - sizeof(struct_objet)); - (*s_etat_processus).depend = (struct_objet *) malloc( - sizeof(struct_objet)); + (*s_etat_processus).indep = allocation(s_etat_processus, NON); + (*s_etat_processus).depend = allocation(s_etat_processus, NON); (*s_etat_processus).parametres_courbes_de_niveau = - (struct_objet *) malloc(sizeof(struct_objet)); + allocation(s_etat_processus, NON); if (((*s_etat_processus).indep != NULL) && ((*s_etat_processus).depend != NULL) && @@ -2130,6 +3415,29 @@ rplinit(int argc, char *argv[], unsigned ((*((*s_etat_processus). parametres_courbes_de_niveau)).objet == NULL)) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + erreur = d_es_allocation_memoire; if ((*s_etat_processus).langue == 'F') @@ -2154,6 +3462,29 @@ rplinit(int argc, char *argv[], unsigned (*((*s_etat_processus).depend)).objet)).nom == NULL)) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + erreur = d_es_allocation_memoire; if ((*s_etat_processus).langue == 'F') @@ -2206,6 +3537,29 @@ rplinit(int argc, char *argv[], unsigned .parametres_courbes_de_niveau)).objet)).donnee == NULL)) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + erreur = d_es_allocation_memoire; if ((*s_etat_processus).langue == 'F') @@ -2234,6 +3588,29 @@ rplinit(int argc, char *argv[], unsigned .objet = malloc(10 * sizeof(unsigned char))) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + erreur = d_es_allocation_memoire; if ((*s_etat_processus).langue == 'F') @@ -2294,20 +3671,6 @@ rplinit(int argc, char *argv[], unsigned (*s_etat_processus).my2_lines = d_faux; (*s_etat_processus).mz2_lines = d_faux; - if ((*s_etat_processus).erreur_systeme != d_es) - { - if ((*s_etat_processus).langue == 'F') - { - printf("+++Système : Mémoire insuffisante\n"); - } - else - { - printf("+++System : Not enough memory\n"); - } - - return(EXIT_FAILURE); - } - (*s_etat_processus).mode_evaluation_expression = 'N'; (*s_etat_processus).mode_execution_programme = 'Y'; @@ -2316,6 +3679,30 @@ rplinit(int argc, char *argv[], unsigned if ((erreur = chainage(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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Fatal :" @@ -2347,6 +3734,29 @@ rplinit(int argc, char *argv[], unsigned if ((erreur = compilation(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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if (traitement_fichier_temporaire == 'Y') { if (destruction_fichier(nom_fichier_temporaire) @@ -2404,8 +3814,31 @@ rplinit(int argc, char *argv[], unsigned (*s_etat_processus).position_courante = 0; (*s_etat_processus).traitement_cycle_exit = 'N'; - if ((*s_etat_processus).nombre_variables == 0) + if ((*s_etat_processus).s_arbre_variables == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Fatal : Aucun point d'entrée\n"); @@ -2426,6 +3859,29 @@ rplinit(int argc, char *argv[], unsigned if (recherche_instruction_suivante(s_etat_processus) == d_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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Fatal : Aucun point d'entrée\n"); @@ -2447,6 +3903,29 @@ rplinit(int argc, char *argv[], unsigned (*s_etat_processus) .instruction_courante) == d_faux) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Fatal : Aucun point d'entrée\n"); @@ -2464,10 +3943,32 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } - if ((*s_etat_processus).s_liste_variables - [(*s_etat_processus) - .position_variable_courante].niveau != 0) + if ((*(*s_etat_processus).pointeur_variable_courante) + .niveau != 0) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Fatal : Aucun point d'entrée\n"); @@ -2493,6 +3994,29 @@ rplinit(int argc, char *argv[], unsigned strlen(ds_fichier_historique) + 2) * sizeof(unsigned char))) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + erreur = d_es_allocation_memoire; if ((*s_etat_processus).langue == 'F') @@ -2511,6 +4035,11 @@ rplinit(int argc, char *argv[], unsigned home, ds_fichier_historique); using_history(); + + // Pour pouvoir utiliser le keymap avant le premier + // appel à readline(). + rl_initialize(); + erreur_historique = read_history( (*s_etat_processus).nom_fichier_historique); @@ -2520,13 +4049,40 @@ rplinit(int argc, char *argv[], unsigned { (*s_etat_processus).erreur_systeme = d_es; encart(s_etat_processus, - (unsigned long) (5 * 1000000)); + (integer8) (5 * 1000000)); if ((*s_etat_processus).erreur_systeme != d_es) { if ((message = messages(s_etat_processus)) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + erreur = d_es_allocation_memoire; if ((*s_etat_processus).langue == 'F') @@ -2552,8 +4108,6 @@ rplinit(int argc, char *argv[], unsigned fflush(stdout); - initialisation_instructions(s_etat_processus); - if (arguments != NULL) { tampon = (*s_etat_processus).definitions_chainees; @@ -2565,6 +4119,33 @@ rplinit(int argc, char *argv[], unsigned { if ((*s_etat_processus).erreur_systeme != d_es) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + erreur = d_es_allocation_memoire; if ((*s_etat_processus).langue == 'F') @@ -2582,6 +4163,33 @@ rplinit(int argc, char *argv[], unsigned } else { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((*s_etat_processus).langue == 'F') { printf("+++Erreur : Erreur de " @@ -2605,6 +4213,30 @@ rplinit(int argc, char *argv[], unsigned if ((*s_etat_processus).erreur_systeme != d_es) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + if ((message = messages(s_etat_processus)) == NULL) { @@ -2635,6 +4267,33 @@ rplinit(int argc, char *argv[], unsigned if ((message = messages(s_etat_processus)) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + erreur = d_es_allocation_memoire; if ((*s_etat_processus).langue == 'F') @@ -2654,6 +4313,30 @@ rplinit(int argc, char *argv[], unsigned printf("%s [%d]\n", message, (int) getpid()); free(message); +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + return(EXIT_FAILURE); } @@ -2664,6 +4347,34 @@ rplinit(int argc, char *argv[], unsigned if ((message = messages(s_etat_processus)) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + + erreur = d_es_allocation_memoire; erreur = d_es_allocation_memoire; if ((*s_etat_processus).langue == 'F') @@ -2683,9 +4394,35 @@ rplinit(int argc, char *argv[], unsigned printf("%s [%d]\n", message, (int) getpid()); free(message); +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + return(EXIT_FAILURE); } + empilement_pile_systeme(s_etat_processus); + if (evaluation(s_etat_processus, s_objet, 'E') == d_erreur) { @@ -2694,6 +4431,33 @@ rplinit(int argc, char *argv[], unsigned if ((message = messages(s_etat_processus)) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + erreur = d_es_allocation_memoire; if ((*s_etat_processus).langue == 'F') @@ -2714,6 +4478,34 @@ rplinit(int argc, char *argv[], unsigned (int) getpid()); free(message); +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + + erreur = d_es_allocation_memoire; return(EXIT_FAILURE); } @@ -2723,6 +4515,33 @@ rplinit(int argc, char *argv[], unsigned if ((message = messages(s_etat_processus)) == NULL) { +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + erreur = d_es_allocation_memoire; if ((*s_etat_processus).langue == 'F') @@ -2743,6 +4562,33 @@ rplinit(int argc, char *argv[], unsigned (int) getpid()); free(message); +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + return(EXIT_FAILURE); } } @@ -2770,6 +4616,100 @@ rplinit(int argc, char *argv[], unsigned if (setjmp(contexte_initial) == 0) { erreur = sequenceur(s_etat_processus); + + if (erreur == d_absence_erreur) + { + if (((*s_etat_processus) + .arret_depuis_abort == 0) && + ((*s_etat_processus).at_exit + != NULL)) + { + // Permet de traiter ATEXIT + // même après réception d'un SIGINT. + (*s_etat_processus) + .var_volatile_alarme = 0; + (*s_etat_processus) + .var_volatile_requete_arret = 0; + + if ((*s_etat_processus).profilage == + d_vrai) + { + profilage(s_etat_processus, + "ATEXIT"); + } + + erreur = evaluation(s_etat_processus, + (*s_etat_processus).at_exit, + 'E'); + + if ((*s_etat_processus).profilage == + d_vrai) + { + profilage(s_etat_processus, NULL); + } + + if (((*s_etat_processus) + .erreur_execution != d_ex) || + ((*s_etat_processus).exception + != d_ep) || ((*s_etat_processus) + .erreur_systeme != d_es)) + { + printf("%s [%d]\n", message = + messages(s_etat_processus), + (int) getpid()); + free(message); + + if (test_cfsf(s_etat_processus, 51) + == d_faux) + { + printf("%s", ds_beep); + } + + if ((*s_etat_processus).core == + d_vrai) + { + printf("\n"); + + if ((*s_etat_processus).langue + == 'F') + { + printf("+++Information : Gé" + "nération du fichie" + "r rpl-core " + "[%d]\n", (int) + getpid()); + } + else + { + printf("+++Information : Wr" + "iting rpl-core fil" + "e [%d]\n", + (int) getpid()); + } + + rplcore(s_etat_processus); + + if ((*s_etat_processus).langue + == 'F') + { + printf("+++Information : Pr" + "ocessus tracé [%d]" + "\n", + (int) getpid()); + } + else + { + printf("+++Information : Do" + "ne [%d]\n", (int) + getpid()); + } + + printf("\n"); + fflush(stdout); + } + } + } + } } } else @@ -2777,22 +4717,109 @@ rplinit(int argc, char *argv[], unsigned if (setjmp(contexte_initial) == 0) { erreur = sequenceur_optimise(s_etat_processus); - } - } - if (erreur == d_absence_erreur) - { - if (((*s_etat_processus).var_volatile_alarme == 0) - && ((*s_etat_processus).arret_depuis_abort - == 0) && ((*s_etat_processus).at_exit - != NULL)) - { - erreur = evaluation(s_etat_processus, - (*s_etat_processus).at_exit, 'E'); + if (erreur == d_absence_erreur) + { + if (((*s_etat_processus) + .arret_depuis_abort == 0) && + ((*s_etat_processus).at_exit + != NULL)) + { + // Permet de traiter ATEXIT + // même après réception d'un SIGINT. + (*s_etat_processus) + .var_volatile_alarme = 0; + (*s_etat_processus) + .var_volatile_requete_arret = 0; + + if ((*s_etat_processus).profilage == + d_vrai) + { + profilage(s_etat_processus, + "ATEXIT"); + } + + erreur = evaluation(s_etat_processus, + (*s_etat_processus).at_exit, + 'E'); + + if ((*s_etat_processus).profilage == + d_vrai) + { + profilage(s_etat_processus, NULL); + } + + if (((*s_etat_processus) + .erreur_execution != d_ex) || + ((*s_etat_processus).exception + != d_ep) || ((*s_etat_processus) + .erreur_systeme != d_es)) + { + printf("%s [%d]\n", message = + messages(s_etat_processus), + (int) getpid()); + free(message); + + if (test_cfsf(s_etat_processus, 51) + == d_faux) + { + printf("%s", ds_beep); + } + + if ((*s_etat_processus).core == + d_vrai) + { + printf("\n"); + + if ((*s_etat_processus).langue + == 'F') + { + printf("+++Information : Gé" + "nération du fichie" + "r rpl-core " + "[%d]\n", (int) + getpid()); + } + else + { + printf("+++Information : Wr" + "iting rpl-core fil" + "e [%d]\n", + (int) getpid()); + } + + rplcore(s_etat_processus); + + if ((*s_etat_processus).langue + == 'F') + { + printf("+++Information : Pr" + "ocessus tracé [%d]" + "\n", + (int) getpid()); + } + else + { + printf("+++Information : Do" + "ne [%d]\n", (int) + getpid()); + } + + printf("\n"); + fflush(stdout); + } + } + } + } } } } + for(i = 0; i < (*s_etat_processus).sections_critiques; i++) + { + pthread_mutex_unlock(&mutex_sections_critiques); + } + liberation(s_etat_processus, (*s_etat_processus).at_exit); liberation(s_etat_processus, (*s_etat_processus).at_poke); @@ -2804,16 +4831,6 @@ rplinit(int argc, char *argv[], unsigned l_element_courant = (*s_etat_processus).liste_mutexes; while(l_element_courant != NULL) { - pthread_mutex_trylock(&((*((struct_mutex *) - (*(*((struct_liste_chainee *) - l_element_courant)).donnee).objet)).mutex)); - pthread_mutex_unlock(&((*((struct_mutex *) - (*(*((struct_liste_chainee *) - l_element_courant)).donnee).objet)).mutex)); - pthread_mutex_destroy(&((*((struct_mutex *) - (*(*((struct_liste_chainee *) - l_element_courant)).donnee).objet)).mutex)); - liberation(s_etat_processus, (*((struct_liste_chainee *) l_element_courant)).donnee); @@ -2832,7 +4849,8 @@ rplinit(int argc, char *argv[], unsigned pthread_cancel((*s_etat_processus).thread_fusible); } - pthread_mutex_lock(&((*s_etat_processus).mutex)); + pthread_mutex_lock(&((*s_etat_processus) + .mutex_pile_processus)); l_element_courant = (void *) (*s_etat_processus) .l_base_pile_processus; @@ -2905,27 +4923,30 @@ rplinit(int argc, char *argv[], unsigned { if ((*s_etat_processus).var_volatile_alarme != 0) { - kill((*(*((struct_processus_fils *) + envoi_signal_processus( + (*(*((struct_processus_fils *) (*(*((struct_liste_chainee *) l_element_courant)).donnee).objet)) - .thread).pid, SIGURG); + .thread).pid, rpl_sigurg); } else { if ((*s_etat_processus).arret_depuis_abort == -1) { - kill((*(*((struct_processus_fils *) + envoi_signal_processus( + (*(*((struct_processus_fils *) (*(*((struct_liste_chainee *) l_element_courant)).donnee).objet)) - .thread).pid, SIGFABORT); + .thread).pid, rpl_sigabort); } else { - kill((*(*((struct_processus_fils *) + envoi_signal_processus( + (*(*((struct_processus_fils *) (*(*((struct_liste_chainee *) l_element_courant)).donnee).objet)) - .thread).pid, SIGFSTOP); + .thread).pid, rpl_sigstop); } } } @@ -2944,31 +4965,32 @@ rplinit(int argc, char *argv[], unsigned if ((*s_etat_processus).var_volatile_alarme != 0) { - pthread_kill((*(*((struct_processus_fils *) + envoi_signal_thread( + (*(*((struct_processus_fils *) (*(*((struct_liste_chainee *) l_element_courant)).donnee).objet)) - .thread).tid, SIGURG); + .thread).tid, rpl_sigurg); } else { if ((*s_etat_processus).arret_depuis_abort == -1) { - pthread_kill( + envoi_signal_thread( (*(*((struct_processus_fils *) (*(*((struct_liste_chainee *) l_element_courant)).donnee) .objet)).thread).tid, - SIGFABORT); + rpl_sigabort); } else { - pthread_kill( + envoi_signal_thread( (*(*((struct_processus_fils *) (*(*((struct_liste_chainee *) l_element_courant)).donnee) .objet)).thread).tid, - SIGFSTOP); + rpl_sigstop); } } } @@ -2997,13 +5019,10 @@ rplinit(int argc, char *argv[], unsigned while((*s_etat_processus).l_base_pile_processus != NULL) { - status = 0; - l_element_courant = (void *) (*s_etat_processus).l_base_pile_processus; - for(i = 0; i < (unsigned long) - (*(*((struct_processus_fils *) + for(i = 0; i < (*(*((struct_processus_fils *) (*(*((struct_liste_chainee *) l_element_courant)).donnee).objet)).thread) .nombre_objets_dans_pipe; i++) @@ -3023,13 +5042,40 @@ rplinit(int argc, char *argv[], unsigned .thread).nombre_objets_dans_pipe--; action.sa_handler = SIG_IGN; - action.sa_flags = SA_ONSTACK; + action.sa_flags = 0; if (sigaction(SIGPIPE, &action, ®istre) != 0) { - pthread_mutex_unlock( - &((*s_etat_processus).mutex)); +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + + pthread_mutex_unlock(&((*s_etat_processus) + .mutex_pile_processus)); return(EXIT_FAILURE); } @@ -3052,14 +5098,42 @@ rplinit(int argc, char *argv[], unsigned if (sigaction(SIGPIPE, ®istre, NULL) != 0) { - pthread_mutex_unlock( - &((*s_etat_processus).mutex)); +# 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); + liberation_queue_signaux(s_etat_processus); + +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + + pthread_mutex_unlock(&((*s_etat_processus) + .mutex_pile_processus)); return(EXIT_FAILURE); } } } - pthread_mutex_unlock(&((*s_etat_processus).mutex)); + pthread_mutex_lock(&((*s_etat_processus) + .mutex_interruptions)); if ((*s_etat_processus) .nombre_interruptions_non_affectees != 0) @@ -3068,11 +5142,18 @@ rplinit(int argc, char *argv[], unsigned s_etat_processus); } + pthread_mutex_unlock(&((*s_etat_processus) + .mutex_interruptions)); + pthread_mutex_unlock(&((*s_etat_processus) + .mutex_pile_processus)); nanosleep(&attente, NULL); - pthread_mutex_lock(&((*s_etat_processus).mutex)); + scrutation_interruptions(s_etat_processus); + pthread_mutex_lock(&((*s_etat_processus) + .mutex_pile_processus)); } - pthread_mutex_unlock(&((*s_etat_processus).mutex)); + pthread_mutex_unlock(&((*s_etat_processus) + .mutex_pile_processus)); erreur_historique = write_history( (*s_etat_processus).nom_fichier_historique); @@ -3222,40 +5303,34 @@ rplinit(int argc, char *argv[], unsigned * le libérer... */ - for(i = 0; i < (*s_etat_processus).nombre_variables; i++) - { - liberation(s_etat_processus, - (*s_etat_processus).s_liste_variables[i].objet); - free((*s_etat_processus).s_liste_variables[i].nom); - } + liberation_arbre_variables_partagees(s_etat_processus, + (*(*s_etat_processus).s_arbre_variables_partagees)); + liberation_arbre_variables(s_etat_processus, + (*s_etat_processus).s_arbre_variables, d_vrai); + free((*s_etat_processus).pointeurs_caracteres_variables); - free((*s_etat_processus).s_liste_variables); + l_element_statique_courant = (*s_etat_processus) + .l_liste_variables_statiques; - for(i = 0; i < (*s_etat_processus) - .nombre_variables_statiques; i++) + while(l_element_statique_courant != NULL) { - liberation(s_etat_processus, (*s_etat_processus) - .s_liste_variables_statiques[i].objet); - free((*s_etat_processus) - .s_liste_variables_statiques[i].nom); + l_element_statique_suivant = + (*l_element_statique_courant).suivant; + free(l_element_statique_courant); + l_element_statique_courant = l_element_statique_suivant; } - free((*s_etat_processus).s_liste_variables_statiques); + l_element_partage_courant = (*(*s_etat_processus) + .l_liste_variables_partagees); - for(i = 0; i < (*((*s_etat_processus) - .s_liste_variables_partagees)).nombre_variables; - i++) + while(l_element_partage_courant != NULL) { - liberation(s_etat_processus, (*((*s_etat_processus) - .s_liste_variables_partagees)).table[i].objet); - free((*((*s_etat_processus) - .s_liste_variables_partagees)).table[i].nom); + l_element_partage_suivant = + (*l_element_partage_courant).suivant; + free(l_element_partage_courant); + l_element_partage_courant = l_element_partage_suivant; } - free((struct_variable_partagee *) - (*((*s_etat_processus).s_liste_variables_partagees)) - .table); - /* * Si resultats est non nul, rplinit a été appelé * depuis rpl() [librpl] et non main(). @@ -3270,8 +5345,9 @@ rplinit(int argc, char *argv[], unsigned { free((*resultats)); - if (((*resultats) = malloc(((*s_etat_processus) - .hauteur_pile_operationnelle + 1) + if (((*resultats) = malloc(((size_t) + ((*s_etat_processus) + .hauteur_pile_operationnelle + 1)) * sizeof(unsigned char **))) != NULL) { (*resultats)[(*s_etat_processus) @@ -3573,11 +5649,7 @@ rplinit(int argc, char *argv[], unsigned if (traitement_fichier_temporaire == 'Y') { - if (destruction_fichier(nom_fichier_temporaire) == d_erreur) - { - return(EXIT_FAILURE); - } - + destruction_fichier(nom_fichier_temporaire); free(nom_fichier_temporaire); } @@ -3591,46 +5663,44 @@ rplinit(int argc, char *argv[], unsigned closelog(); pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes)); - pthread_mutex_destroy(&((*((*s_etat_processus).s_liste_variables_partagees)) - .mutex)); retrait_thread(s_etat_processus); - pthread_mutex_destroy(&((*s_etat_processus).mutex)); + 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)); + pthread_mutex_destroy(&((*s_etat_processus).mutex_signaux)); + pthread_mutex_destroy(&mutex_sections_critiques); + pthread_mutex_destroy(&mutex_liste_variables_partagees); # 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_destroy2((*s_etat_processus).semaphore_fork, sem_fork); + sem_destroy3((*s_etat_processus).semaphore_fork, getpid(), pthread_self(), + SEM_FORK); # endif free((*s_etat_processus).localisation); -# ifndef SEMAPHORES_NOMMES - sem_destroy(&semaphore_liste_threads); -# else - sem_destroy2(semaphore_liste_threads, sem_liste_threads); -# endif -# ifndef SEMAPHORES_NOMMES - sem_post(&semaphore_gestionnaires_signaux); - sem_destroy(&semaphore_gestionnaires_signaux); - sem_destroy(&semaphore_gestionnaires_signaux_atomique); -# else - sem_post(semaphore_gestionnaires_signaux); - sem_destroy2(semaphore_gestionnaires_signaux, sem_gestionnaires_signaux); - sem_destroy2(semaphore_gestionnaires_signaux_atomique, - sem_gestionnaires_signaux_atomique); -# endif - -# ifdef _BROKEN_SIGINFO - destruction_fifos_signaux(s_etat_processus); -# undef return -# endif + destruction_queue_signaux(s_etat_processus); + liberation_contexte_cas(s_etat_processus); free((*s_etat_processus).chemin_fichiers_temporaires); + + if ((*s_etat_processus).requete_redemarrage == d_vrai) + { + if (chdir(repertoire_initial) == 0) + { + execvp(arg_exec[0], &(arg_exec[0])); + } + + erreur = d_erreur; + } + + free(arg_exec); + arret_thread_signaux(s_etat_processus); free(s_etat_processus); # ifdef DEBUG_MEMOIRE @@ -3638,6 +5708,17 @@ rplinit(int argc, char *argv[], unsigned analyse_post_mortem(); # endif +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + stackoverflow_deinstall_handler(); +# endif + +# ifdef HAVE_SIGSEGV_RECOVERY + if (debug == d_faux) + { + sigsegv_deinstall_handler(); + } +# endif + return((erreur == d_absence_erreur) ? EXIT_SUCCESS : EXIT_FAILURE); } @@ -3660,7 +5741,7 @@ informations(struct_processus *s_etat_pr printf(" -l : licence d'utilisation\n"); printf(" -n : ignorance du signal HUP\n"); printf(" -p : précompilation du script avant exécution\n"); - printf(" -P : profilage\n"); + printf(" -P : profilage (-P ou -PP)\n"); printf(" -s : empêchement de l'ouverture de l'écran initial\n"); printf(" -S : exécution du script passé en ligne de commande\n"); printf(" -t : trace\n"); @@ -3681,7 +5762,7 @@ informations(struct_processus *s_etat_pr printf(" -l : prints the user licence of the software\n"); printf(" -n : ignores HUP signal\n"); printf(" -p : precompiles script\n"); - printf(" -P : computes profile data\n"); + printf(" -P : computes profile data (-P or -PP)\n"); printf(" -s : disables splash screen\n"); printf(" -S : executes script written in command line\n"); printf(" -t : enables tracing mode\n"); @@ -3693,4 +5774,74 @@ informations(struct_processus *s_etat_pr return; } + +logical1 +controle_integrite(struct_processus *s_etat_processus, + unsigned char *executable_candidat, unsigned char *executable) +{ + unsigned char *md5; + unsigned char *sha1; + + if (strcmp(executable, "rplpp") == 0) + { + md5 = rplpp_md5; + sha1 = rplpp_sha1; + } + else if (strcmp(executable, "rplfile") == 0) + { + md5 = rplfile_md5; + sha1 = rplfile_sha1; + } + else if (strcmp(executable, "rpliconv") == 0) + { + md5 = rpliconv_md5; + sha1 = rpliconv_sha1; + } + else if (strcmp(executable, "rplawk") == 0) + { + md5 = rplawk_md5; + sha1 = rplawk_sha1; + } + else if (strcmp(executable, "rplconvert") == 0) + { + md5 = rplconvert_md5; + sha1 = rplconvert_sha1; + } + else + { + return(d_faux); + } + + if (controle(s_etat_processus, executable_candidat, "md5", md5) != d_vrai) + { + return(d_faux); + } + + if (controle(s_etat_processus, executable_candidat, "sha1", sha1) != d_vrai) + { + return(d_faux); + } + + return(d_vrai); +} + + +unsigned char * +date_compilation() +{ + unsigned char *date; + + if ((date = malloc((strlen(d_date_en_rpl) + 1) * sizeof(unsigned char))) + == NULL) + { + return(NULL); + } + + strcpy(date, d_date_en_rpl); + + return(date); +} + +#pragma GCC diagnostic pop + // vim: ts=4