--- rpl/src/rpl.c 2011/05/09 13:52:24 1.58.2.4 +++ rpl/src/rpl.c 2011/11/26 10:01:33 1.98 @@ -1,6 +1,6 @@ /* ================================================================================ - RPL/2 (R) version 4.0.24 + RPL/2 (R) version 4.1.5 Copyright (C) 1989-2011 Dr. BERTRAND Joël This file is part of RPL/2. @@ -23,12 +23,6 @@ #define MAIN_RPL #include "rpl-conv.h" -#ifdef IPCS_SYSV -#ifndef OS2 - unsigned char *chemin_semaphores_SysV; -#endif -#endif - /* ================================================================================ @@ -42,11 +36,14 @@ rplinit(int argc, char *argv[], unsigned # include "copyright-conv.h" # include "licence-conv.h" +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + char pile_signaux[SIGSTKSZ]; +# endif + file *f_source; int erreur_historique; int option_P; - int status; logical1 core; logical1 debug; @@ -106,10 +103,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(); @@ -119,18 +115,11 @@ rplinit(int argc, char *argv[], unsigned 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)) + semaphore_gestionnaires_signaux = sem_init2(0, getpid(), SEM_SIGNAUX); + + if (semaphore_gestionnaires_signaux == SEM_FAILED) { erreur = d_es_allocation_memoire; @@ -187,6 +176,8 @@ rplinit(int argc, char *argv[], unsigned (*s_etat_processus).langue = 'E'; } + 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; @@ -205,22 +196,22 @@ rplinit(int argc, char *argv[], unsigned 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') + if (((*s_etat_processus).semaphore_fork = sem_init3(0, getpid(), + pthread_self(), SEM_FORK)) == SEM_FAILED) { - uprintf("+++Système : Mémoire insuffisante\n"); - } - else - { - uprintf("+++System : Not enough memory\n"); - } + if ((*s_etat_processus).langue == 'F') + { + uprintf("+++Système : Mémoire insuffisante\n"); + } + else + { + uprintf("+++System : Not enough memory\n"); + } - return(EXIT_FAILURE); - } + return(EXIT_FAILURE); + } # endif pthread_mutexattr_init(&attributs_mutex); @@ -244,21 +235,8 @@ rplinit(int argc, char *argv[], unsigned (*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); @@ -340,90 +318,40 @@ rplinit(int argc, char *argv[], unsigned home = ""; } - // Initialisation d'une clef - - 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"); - } - - return(EXIT_FAILURE); - } - -# ifndef SEMAPHORES_NOMMES - if (pthread_setspecific(semaphore_fork_processus_courant, - &((*s_etat_processus).semaphore_fork)) != 0) -# 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"); - } - else +# ifdef HAVE_STACK_OVERFLOW_RECOVERY + if (stackoverflow_install_handler(interruption_depassement_pile, + pile_signaux, sizeof(pile_signaux)) != 0) { - printf("+++System : Not enough memory\n"); - } + erreur = d_es_signal; - 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) - { - erreur = d_es_allocation_memoire; + 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"); + } - if ((*s_etat_processus).langue == 'F') - { - printf("+++Système : Mémoire insuffisante\n"); - } - else - { - printf("+++System : Not enough memory\n"); + return(EXIT_FAILURE); } - - return(EXIT_FAILURE); - } - - (*s_etat_processus).pile_signal.ss_flags = 0; - - if (sigaltstack(&((*s_etat_processus).pile_signal), NULL) != 0) - { - erreur = d_es_signal; - +# else if ((*s_etat_processus).langue == 'F') { - printf("+++Système : Initialisation de la pile spécifique de signal" - " impossible\n"); + printf("+++Attention : Le système ne supporte pas de pile " + "alternative\n"); } else { - printf("+++System : Initialization of signal stack failed\n"); + printf("+++Warning : Operating system does not support alternate " + "stack\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) { @@ -442,7 +370,10 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } - if (sigaction(SIGTERM, &action, NULL) != 0) + signal_test = SIGTEST; + kill(getpid(), SIGINT); + + if (signal_test != SIGINT) { erreur = d_es_signal; @@ -459,53 +390,10 @@ 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 ((*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); - } - -# 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; - - if (sigaction(SIGSTART, &action, NULL) != 0) + if (sigaction(SIGTERM, &action, NULL) != 0) { - 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); - } + erreur = d_es_signal; - if (sigaction(SIGCONT, &action, NULL) != 0) - { if ((*s_etat_processus).langue == 'F') { printf("+++Système : Initialisation des signaux POSIX " @@ -519,14 +407,10 @@ 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; + kill(getpid(), SIGTERM); - if (sigaction(SIGFSTOP, &action, NULL) != 0) + if (signal_test != SIGTERM) { erreur = d_es_signal; @@ -543,17 +427,11 @@ 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; - if ((*s_etat_processus).langue == 'F') { printf("+++Système : Initialisation des signaux POSIX " @@ -567,14 +445,10 @@ 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; + kill(getpid(), SIGTSTP); - if (sigaction(SIGURG, &action, NULL) != 0) + if (signal_test != SIGTSTP) { erreur = d_es_signal; @@ -591,12 +465,8 @@ 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) { @@ -615,14 +485,10 @@ 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; + kill(getpid(), SIGPIPE); - if (sigaction(SIGINJECT, &action, NULL) != 0) + if (signal_test != SIGPIPE) { erreur = d_es_signal; @@ -639,14 +505,10 @@ 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) { erreur = d_es_signal; @@ -663,14 +525,10 @@ 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; + kill(getpid(), SIGUSR1); - if (sigaction(SIGALRM, &action, NULL) != 0) + if (signal_test != SIGUSR1) { erreur = d_es_signal; @@ -687,12 +545,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 +593,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] == '-') @@ -1535,6 +1397,12 @@ rplinit(int argc, char *argv[], unsigned break; } + case '-': + case ' ': + { + break; + } + default : { if ((*s_etat_processus).langue == 'F') @@ -1579,8 +1447,37 @@ 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) + { + 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) { if ((*s_etat_processus).langue == 'F') @@ -1597,6 +1494,28 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } + signal_test = SIGTEST; + kill(getpid(), SIGSEGV); + + if (signal_test != SIGSEGV) + { + 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 + if (sigaction(SIGBUS, &action, NULL) != 0) { if ((*s_etat_processus).langue == 'F') @@ -1612,16 +1531,34 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } + + signal_test = SIGTEST; + kill(getpid(), SIGBUS); + + if (signal_test != SIGBUS) + { + 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) { @@ -1862,10 +1799,10 @@ 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).gel_liste_variables = d_faux; - (*s_etat_processus).nombre_variables = 0; - (*s_etat_processus).nombre_variables_allouees = 0; + (*s_etat_processus).pointeur_variable_courante = NULL; (*s_etat_processus).s_liste_variables_statiques = NULL; (*s_etat_processus).nombre_variables_statiques = 0; (*s_etat_processus).nombre_variables_statiques_allouees = 0; @@ -1873,7 +1810,6 @@ rplinit(int argc, char *argv[], unsigned (*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; @@ -2016,9 +1952,13 @@ 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) { @@ -2404,7 +2344,7 @@ 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) { if ((*s_etat_processus).langue == 'F') { @@ -2464,9 +2404,8 @@ 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) { if ((*s_etat_processus).langue == 'F') { @@ -2552,8 +2491,6 @@ rplinit(int argc, char *argv[], unsigned fflush(stdout); - initialisation_instructions(s_etat_processus); - if (arguments != NULL) { tampon = (*s_etat_processus).definitions_chainees; @@ -2770,6 +2707,20 @@ 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).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'); + } + } } } else @@ -2777,18 +2728,20 @@ 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).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'); + } + } } } } @@ -2905,27 +2858,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 +2900,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,8 +2954,6 @@ 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; @@ -3023,7 +2978,7 @@ 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) @@ -3069,6 +3024,7 @@ rplinit(int argc, char *argv[], unsigned } nanosleep(&attente, NULL); + scrutation_interruptions(s_etat_processus); pthread_mutex_lock(&((*s_etat_processus).mutex)); } @@ -3222,14 +3178,9 @@ 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); - } - - free((*s_etat_processus).s_liste_variables); + liberation_arbre_variables(s_etat_processus, + (*s_etat_processus).s_arbre_variables, d_vrai); + free((*s_etat_processus).pointeurs_caracteres_variables); for(i = 0; i < (*s_etat_processus) .nombre_variables_statiques; i++) @@ -3604,31 +3555,25 @@ rplinit(int argc, char *argv[], unsigned 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 + pthread_mutex_destroy(&mutex_liste_threads); + pthread_mutex_destroy(&mutex_gestionnaires_signaux_atomique); + # 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); + sem_destroy2(semaphore_gestionnaires_signaux, getpid(), SEM_SIGNAUX); # 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); free(s_etat_processus); @@ -3638,6 +3583,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); } @@ -3693,4 +3649,21 @@ informations(struct_processus *s_etat_pr return; } + +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); +} + // vim: ts=4