version 1.75, 2011/07/25 07:45:00
|
version 1.107, 2012/01/05 10:19:05
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.2 |
RPL/2 (R) version 4.1.5 |
Copyright (C) 1989-2011 Dr. BERTRAND Joël |
Copyright (C) 1989-2012 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
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 37
|
Line 31
|
*/ |
*/ |
|
|
int |
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 "copyright-conv.h" |
# include "licence-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; |
file *f_source; |
|
|
int erreur_historique; |
int erreur_historique; |
Line 105 rplinit(int argc, char *argv[], unsigned
|
Line 109 rplinit(int argc, char *argv[], unsigned
|
volatile unsigned char traitement_fichier_temporaire; |
volatile unsigned char traitement_fichier_temporaire; |
|
|
errno = 0; |
errno = 0; |
|
s_queue_signaux = NULL; |
|
routine_recursive = 0; |
|
pid_processus_pere = getpid(); |
|
|
# ifdef DEBUG_MEMOIRE |
# ifdef DEBUG_MEMOIRE |
debug_memoire_initialisation(); |
debug_memoire_initialisation(); |
Line 114 rplinit(int argc, char *argv[], unsigned
|
Line 121 rplinit(int argc, char *argv[], unsigned
|
setvbuf(stderr, NULL, _IOLBF, 0); |
setvbuf(stderr, NULL, _IOLBF, 0); |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
sem_init(&semaphore_liste_threads, 0, 1); |
|
sem_init(&semaphore_gestionnaires_signaux, 0, 0); |
sem_init(&semaphore_gestionnaires_signaux, 0, 0); |
sem_init(&semaphore_gestionnaires_signaux_atomique, 0, 1); |
|
# else |
# else |
semaphore_liste_threads = sem_init2(1, sem_liste_threads); |
semaphore_gestionnaires_signaux = sem_init2(0, getpid(), SEM_SIGNAUX); |
semaphore_gestionnaires_signaux = sem_init2(0, sem_gestionnaires_signaux); |
|
semaphore_gestionnaires_signaux_atomique = sem_init2(1, |
if (semaphore_gestionnaires_signaux == SEM_FAILED) |
sem_gestionnaires_signaux_atomique); |
|
|
|
if ((semaphore_liste_threads == SEM_FAILED) || |
|
(semaphore_gestionnaires_signaux == SEM_FAILED) || |
|
(semaphore_gestionnaires_signaux_atomique == SEM_FAILED)) |
|
{ |
{ |
erreur = d_es_allocation_memoire; |
erreur = d_es_allocation_memoire; |
|
|
Line 182 rplinit(int argc, char *argv[], unsigned
|
Line 182 rplinit(int argc, char *argv[], unsigned
|
(*s_etat_processus).langue = 'E'; |
(*s_etat_processus).langue = 'E'; |
} |
} |
|
|
|
if (getcwd(repertoire_initial, RPL_PATH_MAX) == NULL) |
|
{ |
|
if ((langue = getenv("LANG")) != NULL) |
|
{ |
|
if (strncmp(langue, "fr", 2) == 0) |
|
{ |
|
uprintf("+++Système : Mémoire insuffisante\n"); |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
|
|
return(EXIT_FAILURE); |
|
} |
|
|
|
if ((arg_exec = malloc((argc + 1) * sizeof(char *))) == NULL) |
|
{ |
|
if ((langue = getenv("LANG")) != NULL) |
|
{ |
|
if (strncmp(langue, "fr", 2) == 0) |
|
{ |
|
uprintf("+++Système : Mémoire insuffisante\n"); |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
|
|
return(EXIT_FAILURE); |
|
} |
|
|
|
for(i = 0; i < (unsigned long) argc; i++) |
|
{ |
|
arg_exec[i] = argv[i]; |
|
} |
|
|
|
argv[argc] = NULL; |
|
|
|
initialisation_contexte_cas(s_etat_processus); |
|
|
(*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).requete_redemarrage = d_faux; |
(*s_etat_processus).rpl_home = rpl_home; |
(*s_etat_processus).rpl_home = rpl_home; |
|
|
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_init(&attributs_mutex); |
Line 200 rplinit(int argc, char *argv[], unsigned
|
Line 252 rplinit(int argc, char *argv[], unsigned
|
pthread_mutexattr_destroy(&attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); |
sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); |
# else |
# else |
if (((*s_etat_processus).semaphore_fork = sem_init2(0, sem_fork)) == |
if (((*s_etat_processus).semaphore_fork = sem_init3(0, getpid(), |
SEM_FAILED) |
pthread_self(), SEM_FORK)) == SEM_FAILED) |
{ |
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
{ |
uprintf("+++Système : Mémoire insuffisante\n"); |
if ((*s_etat_processus).langue == 'F') |
} |
{ |
else |
uprintf("+++Système : Mémoire insuffisante\n"); |
{ |
} |
uprintf("+++System : Not enough memory\n"); |
else |
} |
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
# endif |
# endif |
|
|
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_init(&attributs_mutex); |
Line 239 rplinit(int argc, char *argv[], unsigned
|
Line 291 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 |
|
|
|
# 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); |
insertion_thread(s_etat_processus, d_vrai); |
|
creation_queue_signaux(s_etat_processus); |
|
|
# ifndef OS2 |
# ifndef OS2 |
localisation_courante(s_etat_processus); |
localisation_courante(s_etat_processus); |
Line 306 rplinit(int argc, char *argv[], unsigned
|
Line 345 rplinit(int argc, char *argv[], unsigned
|
|
|
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("+++Copyright (C) 1989 à 2010, 2011 BERTRAND Joël\n"); |
printf("+++Copyright (C) 1989 à 2011, 2012 BERTRAND Joël\n"); |
} |
} |
else |
else |
{ |
{ |
printf("+++Copyright (C) 1989 to 2010, 2011 BERTRAND Joel\n"); |
printf("+++Copyright (C) 1989 to 2011, 2012 BERTRAND Joel\n"); |
} |
} |
|
|
if (getenv("HOME") != NULL) |
if (getenv("HOME") != NULL) |
Line 335 rplinit(int argc, char *argv[], unsigned
|
Line 374 rplinit(int argc, char *argv[], unsigned
|
home = ""; |
home = ""; |
} |
} |
|
|
// Initialisation d'une clef |
# ifdef HAVE_STACK_OVERFLOW_RECOVERY |
|
if (stackoverflow_install_handler(interruption_depassement_pile, |
if (pthread_key_create(&semaphore_fork_processus_courant, NULL) != 0) |
pile_signaux, sizeof(pile_signaux)) != 0) |
{ |
|
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); |
if ((*s_etat_processus).langue == 'F') |
} |
{ |
|
printf("+++Système : Initialisation de la pile alternative " |
# ifndef SEMAPHORES_NOMMES |
"impossible\n"); |
if (pthread_setspecific(semaphore_fork_processus_courant, |
} |
&((*s_etat_processus).semaphore_fork)) != 0) |
else |
# else |
{ |
if (pthread_setspecific(semaphore_fork_processus_courant, |
printf("+++System : Initialization of alternate " |
(*s_etat_processus).semaphore_fork) != 0) |
"stack failed\n"); |
# endif |
} |
{ |
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
printf("+++Système : Mémoire insuffisante\n"); |
|
} |
|
else |
|
{ |
|
printf("+++System : Not enough memory\n"); |
|
} |
|
|
|
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') |
return(EXIT_FAILURE); |
{ |
|
printf("+++Système : Mémoire insuffisante\n"); |
|
} |
|
else |
|
{ |
|
printf("+++System : Not enough memory\n"); |
|
} |
} |
|
# else |
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') |
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 |
|
|
# ifndef _BROKEN_SIGINFO |
|
action.sa_sigaction = interruption1; |
|
# else |
|
action.sa_handler = interruption1; |
action.sa_handler = interruption1; |
# endif |
action.sa_flags = 0; |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
|
|
|
if (sigaction(SIGINT, &action, NULL) != 0) |
if (sigaction(SIGINT, &action, NULL) != 0) |
{ |
{ |
Line 437 rplinit(int argc, char *argv[], unsigned
|
Line 426 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
if (sigaction(SIGTERM, &action, NULL) != 0) |
signal_test = SIGTEST; |
|
kill(getpid(), SIGINT); |
|
|
|
if (signal_test != SIGINT) |
{ |
{ |
erreur = d_es_signal; |
erreur = d_es_signal; |
|
|
Line 454 rplinit(int argc, char *argv[], unsigned
|
Line 446 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
# ifndef _BROKEN_SIGINFO |
if (sigaction(SIGTERM, &action, NULL) != 0) |
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) |
|
{ |
{ |
|
erreur = d_es_signal; |
|
|
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("+++Système : Initialisation des signaux POSIX " |
printf("+++Système : Initialisation des signaux POSIX " |
Line 476 rplinit(int argc, char *argv[], unsigned
|
Line 463 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
# ifndef _BROKEN_SIGINFO |
signal_test = SIGTEST; |
action.sa_sigaction = interruption4; |
kill(getpid(), SIGTERM); |
# 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 (signal_test != SIGTERM) |
{ |
{ |
|
erreur = d_es_signal; |
|
|
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("+++Système : Initialisation des signaux POSIX " |
printf("+++Système : Initialisation des signaux POSIX " |
Line 499 rplinit(int argc, char *argv[], unsigned
|
Line 483 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
if (sigaction(SIGCONT, &action, NULL) != 0) |
if (sigaction(SIGALRM, &action, NULL) != 0) |
{ |
{ |
|
erreur = d_es_signal; |
|
|
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("+++Système : Initialisation des signaux POSIX " |
printf("+++Système : Initialisation des signaux POSIX " |
Line 514 rplinit(int argc, char *argv[], unsigned
|
Line 500 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
# ifndef _BROKEN_SIGINFO |
signal_test = SIGTEST; |
action.sa_sigaction = interruption5; |
kill(getpid(), SIGALRM); |
# else |
|
action.sa_handler = interruption5; |
|
# endif |
|
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
|
if (sigaction(SIGFSTOP, &action, NULL) != 0) |
if (signal_test != SIGALRM) |
{ |
{ |
erreur = d_es_signal; |
erreur = d_es_signal; |
|
|
Line 538 rplinit(int argc, char *argv[], unsigned
|
Line 520 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_handler = interruption2; |
action.sa_sigaction = interruption11; |
action.sa_flags = 0; |
# else |
|
action.sa_handler = interruption11; |
|
# endif |
|
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
|
if (sigaction(SIGFABORT, &action, NULL) != 0) |
if (sigaction(SIGTSTP, &action, NULL) != 0) |
{ |
{ |
erreur = d_es_signal; |
|
|
|
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("+++Système : Initialisation des signaux POSIX " |
printf("+++Système : Initialisation des signaux POSIX " |
Line 562 rplinit(int argc, char *argv[], unsigned
|
Line 538 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
# ifndef _BROKEN_SIGINFO |
signal_test = SIGTEST; |
action.sa_sigaction = interruption8; |
kill(getpid(), SIGTSTP); |
# else |
|
action.sa_handler = interruption8; |
|
# endif |
|
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
|
if (sigaction(SIGURG, &action, NULL) != 0) |
if (signal_test != SIGTSTP) |
{ |
{ |
erreur = d_es_signal; |
erreur = d_es_signal; |
|
|
Line 586 rplinit(int argc, char *argv[], unsigned
|
Line 558 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_handler = interruption5; |
action.sa_sigaction = interruption7; |
action.sa_flags = 0; |
# else |
|
action.sa_handler = interruption7; |
|
# endif |
|
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
|
if (sigaction(SIGPIPE, &action, NULL) != 0) |
if (sigaction(SIGPIPE, &action, NULL) != 0) |
{ |
{ |
Line 610 rplinit(int argc, char *argv[], unsigned
|
Line 578 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
# ifndef _BROKEN_SIGINFO |
signal_test = SIGTEST; |
action.sa_sigaction = interruption6; |
kill(getpid(), SIGPIPE); |
# else |
|
action.sa_handler = interruption6; |
|
# endif |
|
action.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_NODEFER; |
|
|
|
if (sigaction(SIGINJECT, &action, NULL) != 0) |
if (signal_test != SIGPIPE) |
{ |
{ |
erreur = d_es_signal; |
erreur = d_es_signal; |
|
|
Line 634 rplinit(int argc, char *argv[], unsigned
|
Line 598 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_handler = interruption1; |
action.sa_sigaction = interruption9; |
action.sa_flags = 0; |
# else |
|
action.sa_handler = interruption9; |
|
# endif |
|
action.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_NODEFER; |
|
|
|
if (sigaction(SIGABORT, &action, NULL) != 0) |
if (sigaction(SIGUSR1, &action, NULL) != 0) |
{ |
{ |
erreur = d_es_signal; |
erreur = d_es_signal; |
|
|
Line 658 rplinit(int argc, char *argv[], unsigned
|
Line 618 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
# ifndef _BROKEN_SIGINFO |
signal_test = SIGTEST; |
action.sa_sigaction = interruption1; |
kill(getpid(), SIGUSR1); |
# else |
|
action.sa_handler = interruption1; |
|
# endif |
|
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
|
if (sigaction(SIGALRM, &action, NULL) != 0) |
if (signal_test != SIGUSR1) |
{ |
{ |
erreur = d_es_signal; |
erreur = d_es_signal; |
|
|
Line 682 rplinit(int argc, char *argv[], unsigned
|
Line 638 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
# ifndef _BROKEN_SIGINFO |
signal_test = SIGTEST + 1; |
action.sa_sigaction = interruption3; |
|
# else |
|
action.sa_handler = interruption3; |
|
# endif |
|
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
|
erreur = d_absence_erreur; |
erreur = d_absence_erreur; |
core = d_faux; |
core = d_faux; |
Line 735 rplinit(int argc, char *argv[], unsigned
|
Line 686 rplinit(int argc, char *argv[], unsigned
|
option_t = d_faux; |
option_t = d_faux; |
option_v = 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) |
while((--argc) > 0) |
{ |
{ |
if ((*(++argv))[0] == '-') |
if ((*(++argv))[0] == '-') |
Line 1530 rplinit(int argc, char *argv[], unsigned
|
Line 1490 rplinit(int argc, char *argv[], unsigned
|
break; |
break; |
} |
} |
|
|
|
case '-': |
|
case ' ': |
|
{ |
|
break; |
|
} |
|
|
default : |
default : |
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
Line 1574 rplinit(int argc, char *argv[], unsigned
|
Line 1540 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_flags = 0; |
|
|
if (sigaction(SIGSEGV, &action, NULL) != 0) |
if (sigaction(SIGSEGV, &action, NULL) != 0) |
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
Line 1592 rplinit(int argc, char *argv[], unsigned
|
Line 1587 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 1607 rplinit(int argc, char *argv[], unsigned
|
Line 1624 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) |
{ |
{ |
# ifndef _BROKEN_SIGINFO |
action.sa_handler = interruption4; |
action.sa_sigaction = interruption10; |
action.sa_flags = 0; |
# else |
|
action.sa_handler = interruption10; |
|
# endif |
|
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
|
|
|
if (sigaction(SIGHUP, &action, NULL) != 0) |
if (sigaction(SIGHUP, &action, NULL) != 0) |
{ |
{ |
Line 1997 rplinit(int argc, char *argv[], unsigned
|
Line 2032 rplinit(int argc, char *argv[], unsigned
|
(*s_etat_processus).arbre_instructions = NULL; |
(*s_etat_processus).arbre_instructions = NULL; |
|
|
(*s_etat_processus).tid_processus_pere = pthread_self(); |
(*s_etat_processus).tid_processus_pere = pthread_self(); |
|
(*s_etat_processus).tid= pthread_self(); |
(*s_etat_processus).pid_processus_pere = getpid(); |
(*s_etat_processus).pid_processus_pere = getpid(); |
(*s_etat_processus).processus_detache = d_vrai; |
(*s_etat_processus).processus_detache = d_vrai; |
(*s_etat_processus).var_volatile_processus_pere = -1; |
(*s_etat_processus).var_volatile_processus_pere = -1; |
Line 2010 rplinit(int argc, char *argv[], unsigned
|
Line 2046 rplinit(int argc, char *argv[], unsigned
|
(*s_etat_processus).var_volatile_recursivite = 0; |
(*s_etat_processus).var_volatile_recursivite = 0; |
(*s_etat_processus).var_volatile_exception_gsl = 0; |
(*s_etat_processus).var_volatile_exception_gsl = 0; |
(*s_etat_processus).arret_depuis_abort = 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_allocateur(s_etat_processus); |
initialisation_drapeaux(s_etat_processus); |
initialisation_drapeaux(s_etat_processus); |
Line 2763 rplinit(int argc, char *argv[], unsigned
|
Line 2801 rplinit(int argc, char *argv[], unsigned
|
if (setjmp(contexte_initial) == 0) |
if (setjmp(contexte_initial) == 0) |
{ |
{ |
erreur = sequenceur(s_etat_processus); |
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 |
else |
Line 2770 rplinit(int argc, char *argv[], unsigned
|
Line 2822 rplinit(int argc, char *argv[], unsigned
|
if (setjmp(contexte_initial) == 0) |
if (setjmp(contexte_initial) == 0) |
{ |
{ |
erreur = sequenceur_optimise(s_etat_processus); |
erreur = sequenceur_optimise(s_etat_processus); |
} |
|
} |
|
|
|
if (erreur == d_absence_erreur) |
if (erreur == d_absence_erreur) |
{ |
{ |
if (((*s_etat_processus).var_volatile_alarme == 0) |
if (((*s_etat_processus).var_volatile_alarme |
&& ((*s_etat_processus).arret_depuis_abort |
== 0) && ((*s_etat_processus) |
== 0) && ((*s_etat_processus).at_exit |
.arret_depuis_abort == 0) && |
!= NULL)) |
((*s_etat_processus).at_exit |
{ |
!= NULL)) |
erreur = evaluation(s_etat_processus, |
{ |
(*s_etat_processus).at_exit, 'E'); |
erreur = evaluation(s_etat_processus, |
|
(*s_etat_processus).at_exit, |
|
'E'); |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
Line 2797 rplinit(int argc, char *argv[], unsigned
|
Line 2851 rplinit(int argc, char *argv[], unsigned
|
l_element_courant = (*s_etat_processus).liste_mutexes; |
l_element_courant = (*s_etat_processus).liste_mutexes; |
while(l_element_courant != NULL) |
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, |
liberation(s_etat_processus, |
(*((struct_liste_chainee *) |
(*((struct_liste_chainee *) |
l_element_courant)).donnee); |
l_element_courant)).donnee); |
Line 2898 rplinit(int argc, char *argv[], unsigned
|
Line 2942 rplinit(int argc, char *argv[], unsigned
|
{ |
{ |
if ((*s_etat_processus).var_volatile_alarme != 0) |
if ((*s_etat_processus).var_volatile_alarme != 0) |
{ |
{ |
kill((*(*((struct_processus_fils *) |
envoi_signal_processus( |
|
(*(*((struct_processus_fils *) |
(*(*((struct_liste_chainee *) |
(*(*((struct_liste_chainee *) |
l_element_courant)).donnee).objet)) |
l_element_courant)).donnee).objet)) |
.thread).pid, SIGURG); |
.thread).pid, rpl_sigurg); |
} |
} |
else |
else |
{ |
{ |
if ((*s_etat_processus).arret_depuis_abort |
if ((*s_etat_processus).arret_depuis_abort |
== -1) |
== -1) |
{ |
{ |
kill((*(*((struct_processus_fils *) |
envoi_signal_processus( |
|
(*(*((struct_processus_fils *) |
(*(*((struct_liste_chainee *) |
(*(*((struct_liste_chainee *) |
l_element_courant)).donnee).objet)) |
l_element_courant)).donnee).objet)) |
.thread).pid, SIGFABORT); |
.thread).pid, rpl_sigabort); |
} |
} |
else |
else |
{ |
{ |
kill((*(*((struct_processus_fils *) |
envoi_signal_processus( |
|
(*(*((struct_processus_fils *) |
(*(*((struct_liste_chainee *) |
(*(*((struct_liste_chainee *) |
l_element_courant)).donnee).objet)) |
l_element_courant)).donnee).objet)) |
.thread).pid, SIGFSTOP); |
.thread).pid, rpl_sigstop); |
} |
} |
} |
} |
} |
} |
Line 2937 rplinit(int argc, char *argv[], unsigned
|
Line 2984 rplinit(int argc, char *argv[], unsigned
|
if ((*s_etat_processus).var_volatile_alarme |
if ((*s_etat_processus).var_volatile_alarme |
!= 0) |
!= 0) |
{ |
{ |
pthread_kill((*(*((struct_processus_fils *) |
envoi_signal_thread( |
|
(*(*((struct_processus_fils *) |
(*(*((struct_liste_chainee *) |
(*(*((struct_liste_chainee *) |
l_element_courant)).donnee).objet)) |
l_element_courant)).donnee).objet)) |
.thread).tid, SIGURG); |
.thread).tid, rpl_sigurg); |
} |
} |
else |
else |
{ |
{ |
if ((*s_etat_processus).arret_depuis_abort |
if ((*s_etat_processus).arret_depuis_abort |
== -1) |
== -1) |
{ |
{ |
pthread_kill( |
envoi_signal_thread( |
(*(*((struct_processus_fils *) |
(*(*((struct_processus_fils *) |
(*(*((struct_liste_chainee *) |
(*(*((struct_liste_chainee *) |
l_element_courant)).donnee) |
l_element_courant)).donnee) |
.objet)).thread).tid, |
.objet)).thread).tid, |
SIGFABORT); |
rpl_sigabort); |
} |
} |
else |
else |
{ |
{ |
pthread_kill( |
envoi_signal_thread( |
(*(*((struct_processus_fils *) |
(*(*((struct_processus_fils *) |
(*(*((struct_liste_chainee *) |
(*(*((struct_liste_chainee *) |
l_element_courant)).donnee) |
l_element_courant)).donnee) |
.objet)).thread).tid, |
.objet)).thread).tid, |
SIGFSTOP); |
rpl_sigstop); |
} |
} |
} |
} |
} |
} |
Line 3014 rplinit(int argc, char *argv[], unsigned
|
Line 3062 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 3060 rplinit(int argc, char *argv[], unsigned
|
Line 3108 rplinit(int argc, char *argv[], unsigned
|
} |
} |
|
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
|
scrutation_interruptions(s_etat_processus); |
pthread_mutex_lock(&((*s_etat_processus).mutex)); |
pthread_mutex_lock(&((*s_etat_processus).mutex)); |
} |
} |
|
|
Line 3590 rplinit(int argc, char *argv[], unsigned
|
Line 3639 rplinit(int argc, char *argv[], unsigned
|
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
# else |
# else |
sem_post((*s_etat_processus).semaphore_fork); |
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 |
# endif |
|
|
free((*s_etat_processus).localisation); |
free((*s_etat_processus).localisation); |
|
|
# ifndef SEMAPHORES_NOMMES |
pthread_mutex_destroy(&mutex_liste_threads); |
sem_destroy(&semaphore_liste_threads); |
pthread_mutex_destroy(&mutex_gestionnaires_signaux_atomique); |
# else |
|
sem_destroy2(semaphore_liste_threads, sem_liste_threads); |
|
# endif |
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
sem_post(&semaphore_gestionnaires_signaux); |
sem_post(&semaphore_gestionnaires_signaux); |
sem_destroy(&semaphore_gestionnaires_signaux); |
sem_destroy(&semaphore_gestionnaires_signaux); |
sem_destroy(&semaphore_gestionnaires_signaux_atomique); |
|
# 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); |
sem_destroy2(semaphore_gestionnaires_signaux_atomique, |
|
sem_gestionnaires_signaux_atomique); |
|
# endif |
# endif |
|
|
# ifdef _BROKEN_SIGINFO |
destruction_queue_signaux(s_etat_processus); |
destruction_fifos_signaux(s_etat_processus); |
liberation_contexte_cas(s_etat_processus); |
# undef return |
|
# endif |
|
|
|
free((*s_etat_processus).chemin_fichiers_temporaires); |
free((*s_etat_processus).chemin_fichiers_temporaires); |
|
|
|
if ((*s_etat_processus).requete_redemarrage == d_vrai) |
|
{ |
|
chdir(repertoire_initial); |
|
execvp(arg_exec[0], &(arg_exec[0])); |
|
erreur = d_erreur; |
|
} |
|
|
|
free(arg_exec); |
free(s_etat_processus); |
free(s_etat_processus); |
|
|
# ifdef DEBUG_MEMOIRE |
# ifdef DEBUG_MEMOIRE |
Line 3624 rplinit(int argc, char *argv[], unsigned
|
Line 3676 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); |
} |
} |
|
|
Line 3679 informations(struct_processus *s_etat_pr
|
Line 3742 informations(struct_processus *s_etat_pr
|
return; |
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); |
|
} |
|
|
// vim: ts=4 |
// vim: ts=4 |