version 1.93, 2011/09/20 19:28:39
|
version 1.95, 2011/09/26 15:57:17
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.3 |
RPL/2 (R) version 4.1.4 |
Copyright (C) 1989-2011 Dr. BERTRAND Joël |
Copyright (C) 1989-2011 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
Line 36 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 100 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 176 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 314 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 (sigaltstack(&((*s_etat_processus).pile_signal), NULL) != 0) |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
erreur = d_es_signal; |
printf("+++Système : Initialisation de la pile alternative " |
|
"impossible\n"); |
|
} |
|
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 434 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 472 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 512 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 532 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 1453 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 1474 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 1489 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 2914 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 3519 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); |
} |
} |
|
|