version 1.86, 2011/09/16 09:09:35
|
version 1.94, 2011/09/21 09:09:01
|
Line 23
|
Line 23
|
#define MAIN_RPL |
#define MAIN_RPL |
#include "rpl-conv.h" |
#include "rpl-conv.h" |
|
|
#ifdef IPCS_SYSV |
|
#ifndef OS2 |
|
unsigned char *chemin_semaphores_SysV; |
|
#endif |
|
#endif |
|
|
|
|
|
/* |
/* |
================================================================================ |
================================================================================ |
Line 42 rplinit(int argc, char *argv[], unsigned
|
Line 36 rplinit(int argc, char *argv[], unsigned
|
# include "copyright-conv.h" |
# include "copyright-conv.h" |
# include "licence-conv.h" |
# include "licence-conv.h" |
|
|
|
char pile_signaux[SIGSTKSZ]; |
|
|
file *f_source; |
file *f_source; |
|
|
int erreur_historique; |
int erreur_historique; |
Line 106 rplinit(int argc, char *argv[], unsigned
|
Line 102 rplinit(int argc, char *argv[], unsigned
|
|
|
errno = 0; |
errno = 0; |
s_queue_signaux = NULL; |
s_queue_signaux = NULL; |
|
routine_recursive = 0; |
pid_processus_pere = getpid(); |
pid_processus_pere = getpid(); |
|
|
# ifdef DEBUG_MEMOIRE |
# ifdef DEBUG_MEMOIRE |
Line 118 rplinit(int argc, char *argv[], unsigned
|
Line 115 rplinit(int argc, char *argv[], unsigned
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
sem_init(&semaphore_gestionnaires_signaux, 0, 0); |
sem_init(&semaphore_gestionnaires_signaux, 0, 0); |
# else |
# else |
semaphore_gestionnaires_signaux = sem_init2(0, sem_gestionnaires_signaux); |
semaphore_gestionnaires_signaux = sem_init2(0, getpid(), SEM_SIGNAUX); |
|
|
if (semaphore_gestionnaires_signaux == SEM_FAILED) |
if (semaphore_gestionnaires_signaux == SEM_FAILED) |
{ |
{ |
Line 182 rplinit(int argc, char *argv[], unsigned
|
Line 179 rplinit(int argc, char *argv[], unsigned
|
(*s_etat_processus).exception = d_ep; |
(*s_etat_processus).exception = d_ep; |
(*s_etat_processus).erreur_systeme = d_es; |
(*s_etat_processus).erreur_systeme = d_es; |
(*s_etat_processus).erreur_execution = d_ex; |
(*s_etat_processus).erreur_execution = d_ex; |
(*s_etat_processus).compteur_violation_d_acces = 0; |
|
|
|
(*s_etat_processus).rpl_home = rpl_home; |
(*s_etat_processus).rpl_home = rpl_home; |
|
|
Line 197 rplinit(int argc, char *argv[], unsigned
|
Line 193 rplinit(int argc, char *argv[], unsigned
|
&attributs_mutex); |
&attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
pthread_mutexattr_init(&attributs_mutex); |
# ifndef SEMAPHORES_NOMMES |
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); |
pthread_mutex_init(&((*s_etat_processus).mutex_fork), |
# else |
&attributs_mutex); |
if (((*s_etat_processus).semaphore_fork = sem_init3(0, getpid(), |
pthread_mutexattr_destroy(&attributs_mutex); |
pthread_self(), SEM_FORK)) == SEM_FAILED) |
pthread_mutex_lock(&((*s_etat_processus).mutex_fork)); |
{ |
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
uprintf("+++Système : Mémoire insuffisante\n"); |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
|
|
return(EXIT_FAILURE); |
|
} |
|
# endif |
|
|
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
Line 225 rplinit(int argc, char *argv[], unsigned
|
Line 233 rplinit(int argc, char *argv[], unsigned
|
(*s_etat_processus).chemin_fichiers_temporaires = |
(*s_etat_processus).chemin_fichiers_temporaires = |
recherche_chemin_fichiers_temporaires(s_etat_processus); |
recherche_chemin_fichiers_temporaires(s_etat_processus); |
|
|
# ifdef IPCS_SYSV |
|
# ifndef OS2 |
|
chemin_semaphores_SysV = |
|
(*s_etat_processus).chemin_fichiers_temporaires; |
|
# endif |
|
# endif |
|
|
|
insertion_thread(s_etat_processus, d_vrai); |
insertion_thread(s_etat_processus, d_vrai); |
creation_queue_signaux(s_etat_processus); |
creation_queue_signaux(s_etat_processus); |
|
|
Line 315 rplinit(int argc, char *argv[], unsigned
|
Line 316 rplinit(int argc, char *argv[], unsigned
|
home = ""; |
home = ""; |
} |
} |
|
|
// Initialisation d'une pile de signal pour récupérer les |
# ifdef HAVE_STACK_OVERFLOW_RECOVERY |
// débordement de pile |
if (stackoverflow_install_handler(interruption_depassement_pile, |
|
pile_signaux, sizeof(pile_signaux)) != 0) |
# 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 : Mémoire insuffisante\n"); |
erreur = d_es_signal; |
} |
|
else |
|
{ |
|
printf("+++System : Not enough memory\n"); |
|
} |
|
|
|
return(EXIT_FAILURE); |
|
} |
|
|
|
(*s_etat_processus).pile_signal.ss_flags = 0; |
if ((*s_etat_processus).langue == 'F') |
|
{ |
if (sigaltstack(&((*s_etat_processus).pile_signal), NULL) != 0) |
printf("+++Système : Initialisation de la pile alternative " |
{ |
"impossible\n"); |
erreur = d_es_signal; |
} |
|
else |
|
{ |
|
printf("+++System : Initialization of alternate " |
|
"stack failed\n"); |
|
} |
|
|
|
return(EXIT_FAILURE); |
|
} |
|
# else |
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("+++Système : Initialisation de la pile spécifique de signal" |
printf("+++Attention : Le système ne supporte pas de pile " |
" impossible\n"); |
"alternative\n"); |
} |
} |
else |
else |
{ |
{ |
printf("+++System : Initialization of signal stack failed\n"); |
printf("+++Warning : Operating system does not support alternate " |
|
"stack\n"); |
} |
} |
|
|
return(EXIT_FAILURE); |
|
} |
|
# endif |
# endif |
|
|
action.sa_handler = interruption1; |
action.sa_handler = interruption1; |
action.sa_flags = SA_ONSTACK; |
action.sa_flags = 0; |
|
|
if (sigaction(SIGINT, &action, NULL) != 0) |
if (sigaction(SIGINT, &action, NULL) != 0) |
{ |
{ |
Line 435 rplinit(int argc, char *argv[], unsigned
|
Line 426 rplinit(int argc, char *argv[], unsigned
|
} |
} |
|
|
action.sa_handler = interruption2; |
action.sa_handler = interruption2; |
action.sa_flags = SA_NODEFER | SA_ONSTACK; |
action.sa_flags = 0; |
|
|
if (sigaction(SIGTSTP, &action, NULL) != 0) |
if (sigaction(SIGTSTP, &action, NULL) != 0) |
{ |
{ |
Line 473 rplinit(int argc, char *argv[], unsigned
|
Line 464 rplinit(int argc, char *argv[], unsigned
|
} |
} |
|
|
action.sa_handler = interruption5; |
action.sa_handler = interruption5; |
action.sa_flags = SA_NODEFER | SA_ONSTACK; |
action.sa_flags = 0; |
|
|
if (sigaction(SIGPIPE, &action, NULL) != 0) |
if (sigaction(SIGPIPE, &action, NULL) != 0) |
{ |
{ |
Line 513 rplinit(int argc, char *argv[], unsigned
|
Line 504 rplinit(int argc, char *argv[], unsigned
|
} |
} |
|
|
action.sa_handler = interruption1; |
action.sa_handler = interruption1; |
action.sa_flags = SA_NODEFER | SA_ONSTACK; |
action.sa_flags = 0; |
|
|
if (sigaction(SIGALRM, &action, NULL) != 0) |
if (sigaction(SIGUSR1, &action, NULL) != 0) |
{ |
{ |
erreur = d_es_signal; |
erreur = d_es_signal; |
|
|
Line 533 rplinit(int argc, char *argv[], unsigned
|
Line 524 rplinit(int argc, char *argv[], unsigned
|
} |
} |
|
|
signal_test = SIGTEST; |
signal_test = SIGTEST; |
kill(getpid(), SIGALRM); |
kill(getpid(), SIGUSR1); |
|
|
if (signal_test != SIGALRM) |
if (signal_test != SIGUSR1) |
{ |
{ |
erreur = d_es_signal; |
erreur = d_es_signal; |
|
|
Line 1454 rplinit(int argc, char *argv[], unsigned
|
Line 1445 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) |
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_handler = interruption3; |
action.sa_flags = SA_NODEFER | SA_ONSTACK; |
action.sa_flags = 0; |
|
|
if (sigaction(SIGSEGV, &action, NULL) != 0) |
if (sigaction(SIGSEGV, &action, NULL) != 0) |
{ |
{ |
Line 1475 rplinit(int argc, char *argv[], unsigned
|
Line 1492 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
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 (sigaction(SIGBUS, &action, NULL) != 0) |
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
Line 1490 rplinit(int argc, char *argv[], unsigned
|
Line 1529 rplinit(int argc, char *argv[], unsigned
|
|
|
return(EXIT_FAILURE); |
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) |
if (option_n == d_vrai) |
{ |
{ |
action.sa_handler = interruption4; |
action.sa_handler = interruption4; |
action.sa_flags = SA_ONSTACK; |
action.sa_flags = 0; |
|
|
if (sigaction(SIGHUP, &action, NULL) != 0) |
if (sigaction(SIGHUP, &action, NULL) != 0) |
{ |
{ |
Line 2639 rplinit(int argc, char *argv[], unsigned
|
Line 2700 rplinit(int argc, char *argv[], unsigned
|
lancement_daemon(s_etat_processus); |
lancement_daemon(s_etat_processus); |
} |
} |
|
|
// A FIXER |
|
// création signaux |
|
if (option_p == d_faux) |
if (option_p == d_faux) |
{ |
{ |
if (setjmp(contexte_initial) == 0) |
if (setjmp(contexte_initial) == 0) |
Line 2683 rplinit(int argc, char *argv[], unsigned
|
Line 2742 rplinit(int argc, char *argv[], unsigned
|
} |
} |
} |
} |
} |
} |
// A FIXER |
|
// destruction signaux |
|
} |
} |
|
|
liberation(s_etat_processus, (*s_etat_processus).at_exit); |
liberation(s_etat_processus, (*s_etat_processus).at_exit); |
Line 2919 rplinit(int argc, char *argv[], unsigned
|
Line 2976 rplinit(int argc, char *argv[], unsigned
|
.thread).nombre_objets_dans_pipe--; |
.thread).nombre_objets_dans_pipe--; |
|
|
action.sa_handler = SIG_IGN; |
action.sa_handler = SIG_IGN; |
action.sa_flags = SA_ONSTACK; |
action.sa_flags = 0; |
|
|
if (sigaction(SIGPIPE, &action, ®istre) |
if (sigaction(SIGPIPE, &action, ®istre) |
!= 0) |
!= 0) |
Line 3491 rplinit(int argc, char *argv[], unsigned
|
Line 3548 rplinit(int argc, char *argv[], unsigned
|
pthread_mutex_destroy(&((*s_etat_processus).mutex)); |
pthread_mutex_destroy(&((*s_etat_processus).mutex)); |
pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation)); |
pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation)); |
|
|
pthread_mutex_unlock(&((*s_etat_processus).mutex_fork)); |
# ifndef SEMAPHORES_NOMMES |
pthread_mutex_destroy(&((*s_etat_processus).mutex_fork)); |
sem_post(&((*s_etat_processus).semaphore_fork)); |
|
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
|
# else |
|
sem_post((*s_etat_processus).semaphore_fork); |
|
sem_destroy3((*s_etat_processus).semaphore_fork, getpid(), pthread_self(), |
|
SEM_FORK); |
|
# endif |
|
|
free((*s_etat_processus).localisation); |
free((*s_etat_processus).localisation); |
|
|
Line 3504 rplinit(int argc, char *argv[], unsigned
|
Line 3567 rplinit(int argc, char *argv[], unsigned
|
sem_destroy(&semaphore_gestionnaires_signaux); |
sem_destroy(&semaphore_gestionnaires_signaux); |
# else |
# else |
sem_post(semaphore_gestionnaires_signaux); |
sem_post(semaphore_gestionnaires_signaux); |
sem_destroy2(semaphore_gestionnaires_signaux, sem_gestionnaires_signaux); |
sem_destroy2(semaphore_gestionnaires_signaux, getpid(), SEM_SIGNAUX); |
# endif |
# endif |
|
|
destruction_queue_signaux(s_etat_processus); |
destruction_queue_signaux(s_etat_processus); |
Line 3518 rplinit(int argc, char *argv[], unsigned
|
Line 3581 rplinit(int argc, char *argv[], unsigned
|
analyse_post_mortem(); |
analyse_post_mortem(); |
# endif |
# 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); |
return((erreur == d_absence_erreur) ? EXIT_SUCCESS : EXIT_FAILURE); |
} |
} |
|
|