--- rpl/src/rpl.c 2010/08/09 13:51:47 1.37 +++ rpl/src/rpl.c 2010/08/22 16:38:36 1.42 @@ -24,8 +24,10 @@ #include "rpl-conv.h" #ifdef SEMAPHORES_SYSV +#ifndef OS2 unsigned char *chemin_semaphores_SysV; #endif +#endif /* @@ -187,8 +189,6 @@ rplinit(int argc, char *argv[], unsigned (*s_etat_processus).rpl_home = rpl_home; - insertion_thread(s_etat_processus, d_vrai); - pthread_mutexattr_init(&attributs_mutex); pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); pthread_mutex_init(&((*s_etat_processus).mutex), &attributs_mutex); @@ -237,6 +237,45 @@ rplinit(int argc, char *argv[], unsigned .mutex), &attributs_mutex); pthread_mutexattr_destroy(&attributs_mutex); + (*s_etat_processus).chemin_fichiers_temporaires = + recherche_chemin_fichiers_temporaires(s_etat_processus); + +# ifdef SEMAPHORES_SYSV +# ifndef OS2 + chemin_semaphores_SysV = (*s_etat_processus).chemin_fichiers_temporaires; +# endif +# endif + +# ifdef _BROKEN_SIGINFO + creation_fifos_signaux(s_etat_processus); + + if ((*s_etat_processus).erreur_systeme != d_es) + { + if (((*s_etat_processus).localisation = malloc((strlen(d_locale) + 1) * + sizeof(unsigned char))) == NULL) + { + if ((*s_etat_processus).langue == 'F') + { + uprintf("+++Système : Mémoire insuffisante\n"); + } + else + { + uprintf("+++System : Not enough memory\n"); + } + + return(EXIT_FAILURE); + } + + strcpy((*s_etat_processus).localisation, d_locale); + } +# ifdef return +# undef return +# endif +# define return destruction_fifos_signaux(s_etat_processus); return +# endif + + insertion_thread(s_etat_processus, d_vrai); + localisation_courante(s_etat_processus); (*s_etat_processus).erreur_systeme = d_es; @@ -333,7 +372,7 @@ rplinit(int argc, char *argv[], unsigned // Initialisation d'une pile de signal pour récupérer les // débordement de pile -# if !defined(Cygwin) +# if !defined(Cygwin) && !defined(OpenBSD) if (((*s_etat_processus).pile_signal.ss_sp = malloc((*s_etat_processus).pile_signal.ss_size = SIGSTKSZ)) == NULL) @@ -372,7 +411,11 @@ rplinit(int argc, char *argv[], unsigned } # endif +# ifndef _BROKEN_SIGINFO action.sa_sigaction = interruption1; +# else + action.sa_handler = interruption1; +# endif action.sa_flags = SA_ONSTACK | SA_SIGINFO; if (sigaction(SIGINT, &action, NULL) != 0) @@ -392,7 +435,11 @@ 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) @@ -410,7 +457,12 @@ 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; if (sigaction(SIGSTART, &action, NULL) != 0) @@ -443,7 +495,11 @@ 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; if (sigaction(SIGFSTOP, &action, NULL) != 0) @@ -463,7 +519,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; if (sigaction(SIGFABORT, &action, NULL) != 0) @@ -483,7 +543,11 @@ 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; if (sigaction(SIGURG, &action, NULL) != 0) @@ -503,7 +567,11 @@ 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; if (sigaction(SIGPIPE, &action, NULL) != 0) @@ -523,8 +591,12 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } +# ifndef _BROKEN_SIGINFO action.sa_sigaction = interruption6; - action.sa_flags = SA_ONSTACK | SA_SIGINFO; +# else + action.sa_handler = interruption6; +# endif + action.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_NODEFER; if (sigaction(SIGINJECT, &action, NULL) != 0) { @@ -543,8 +615,12 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } +# ifndef _BROKEN_SIGINFO action.sa_sigaction = interruption9; - action.sa_flags = SA_ONSTACK | SA_SIGINFO; +# else + action.sa_handler = interruption9; +# endif + action.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_NODEFER; if (sigaction(SIGABORT, &action, NULL) != 0) { @@ -563,7 +639,11 @@ 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; if (sigaction(SIGALRM, &action, NULL) != 0) @@ -583,15 +663,12 @@ rplinit(int argc, char *argv[], unsigned return(EXIT_FAILURE); } +# ifndef _BROKEN_SIGINFO action.sa_sigaction = interruption3; - action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; - - (*s_etat_processus).chemin_fichiers_temporaires = - recherche_chemin_fichiers_temporaires(s_etat_processus); - -# ifdef OS2 - chemin_semaphores_SysV = (*s_etat_processus).chemin_fichiers_temporaires; +# else + action.sa_handler = interruption3; # endif + action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; erreur = d_absence_erreur; core = d_faux; @@ -1515,7 +1592,11 @@ rplinit(int argc, char *argv[], unsigned 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; if (sigaction(SIGHUP, &action, NULL) != 0) @@ -1970,7 +2051,7 @@ rplinit(int argc, char *argv[], unsigned free((*s_etat_processus).instruction_courante); - if ((*s_etat_processus).erreur_systeme == d_es_allocation_memoire) + if ((*s_etat_processus).erreur_systeme != d_es) { erreur = d_es_allocation_memoire; } @@ -3421,8 +3502,6 @@ rplinit(int argc, char *argv[], unsigned l_element_courant = l_element_suivant; } - free((*s_etat_processus).chemin_fichiers_temporaires); - l_element_courant = (*s_etat_processus).s_marques; while(l_element_courant != NULL) { @@ -3474,7 +3553,7 @@ rplinit(int argc, char *argv[], unsigned } } -# ifndef Cygwin +# if !defined(Cygwin) && !defined(OpenBSD) (*s_etat_processus).pile_signal.ss_flags = SS_DISABLE; sigaltstack(&((*s_etat_processus).pile_signal), NULL); free((*s_etat_processus).pile_signal.ss_sp); @@ -3517,6 +3596,12 @@ rplinit(int argc, char *argv[], unsigned sem_gestionnaires_signaux_atomique); # endif +# ifdef _BROKEN_SIGINFO + destruction_fifos_signaux(s_etat_processus); +# undef return +# endif + + free((*s_etat_processus).chemin_fichiers_temporaires); free(s_etat_processus); # ifdef DEBUG_MEMOIRE