version 1.26, 2010/05/24 10:58:37
|
version 1.56, 2010/12/21 13:47:19
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.16 |
RPL/2 (R) version 4.0.20 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
Line 21
|
Line 21
|
|
|
|
|
#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 33
|
Line 39
|
int |
int |
rplinit(int argc, char *argv[], unsigned char ***resultats, char *rpl_home) |
rplinit(int argc, char *argv[], unsigned char ***resultats, char *rpl_home) |
{ |
{ |
# include "copyright.conv.h" |
# include "copyright-conv.h" |
# include "licence.conv.h" |
# include "licence-conv.h" |
|
|
file *f_source; |
file *f_source; |
|
|
Line 99 rplinit(int argc, char *argv[], unsigned
|
Line 105 rplinit(int argc, char *argv[], unsigned
|
volatile int erreur; |
volatile int erreur; |
volatile unsigned char traitement_fichier_temporaire; |
volatile unsigned char traitement_fichier_temporaire; |
|
|
|
errno = 0; |
|
|
|
# ifdef DMALLOC |
|
atexit(dmalloc_shutdown()); |
|
# endif |
|
|
|
# ifdef DEBUG_MEMOIRE |
|
debug_memoire_initialisation(); |
|
# endif |
|
|
setvbuf(stdout, NULL, _IOLBF, 0); |
setvbuf(stdout, NULL, _IOLBF, 0); |
setvbuf(stderr, NULL, _IOLBF, 0); |
setvbuf(stderr, NULL, _IOLBF, 0); |
|
|
Line 177 rplinit(int argc, char *argv[], unsigned
|
Line 193 rplinit(int argc, char *argv[], unsigned
|
|
|
(*s_etat_processus).rpl_home = rpl_home; |
(*s_etat_processus).rpl_home = rpl_home; |
|
|
insertion_thread(s_etat_processus, d_vrai); |
|
|
|
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); |
pthread_mutex_init(&((*s_etat_processus).mutex), &attributs_mutex); |
pthread_mutex_init(&((*s_etat_processus).mutex), &attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
|
pthread_mutexattr_init(&attributs_mutex); |
|
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
|
pthread_mutex_init(&((*s_etat_processus).mutex_allocation), |
|
&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 |
Line 221 rplinit(int argc, char *argv[], unsigned
|
Line 241 rplinit(int argc, char *argv[], unsigned
|
.mutex), &attributs_mutex); |
.mutex), &attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
|
(*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); |
|
|
|
# ifndef OS2 |
localisation_courante(s_etat_processus); |
localisation_courante(s_etat_processus); |
|
# else |
|
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); |
|
} |
|
# endif |
|
|
(*s_etat_processus).erreur_systeme = d_es; |
(*s_etat_processus).erreur_systeme = d_es; |
|
|
if ((*s_etat_processus).localisation == NULL) |
if ((*s_etat_processus).localisation == NULL) |
Line 317 rplinit(int argc, char *argv[], unsigned
|
Line 379 rplinit(int argc, char *argv[], unsigned
|
// Initialisation d'une pile de signal pour récupérer les |
// Initialisation d'une pile de signal pour récupérer les |
// débordement de pile |
// débordement de pile |
|
|
# ifndef Cygwin |
# if !defined(Cygwin) && !defined(OpenBSD) |
if (((*s_etat_processus).pile_signal.ss_sp = |
if (((*s_etat_processus).pile_signal.ss_sp = |
malloc((*s_etat_processus).pile_signal.ss_size = |
malloc((*s_etat_processus).pile_signal.ss_size = |
SIGSTKSZ)) == NULL) |
SIGSTKSZ)) == NULL) |
Line 356 rplinit(int argc, char *argv[], unsigned
|
Line 418 rplinit(int argc, char *argv[], unsigned
|
} |
} |
# endif |
# endif |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption1; |
action.sa_sigaction = interruption1; |
|
# else |
|
action.sa_handler = interruption1; |
|
# endif |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGINT, &action, NULL) != 0) |
if (sigaction(SIGINT, &action, NULL) != 0) |
Line 376 rplinit(int argc, char *argv[], unsigned
|
Line 442 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
if (sigaction(SIGTERM, &action, NULL) != 0) |
|
{ |
|
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); |
|
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption2; |
action.sa_sigaction = interruption2; |
|
# else |
|
action.sa_handler = interruption2; |
|
# endif |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGTSTP, &action, NULL) != 0) |
if (sigaction(SIGTSTP, &action, NULL) != 0) |
Line 394 rplinit(int argc, char *argv[], unsigned
|
Line 481 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption4; |
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; |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGSTART, &action, NULL) != 0) |
if (sigaction(SIGSTART, &action, NULL) != 0) |
Line 427 rplinit(int argc, char *argv[], unsigned
|
Line 519 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption5; |
action.sa_sigaction = interruption5; |
|
# else |
|
action.sa_handler = interruption5; |
|
# endif |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGFSTOP, &action, NULL) != 0) |
if (sigaction(SIGFSTOP, &action, NULL) != 0) |
Line 447 rplinit(int argc, char *argv[], unsigned
|
Line 543 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption11; |
action.sa_sigaction = interruption11; |
|
# else |
|
action.sa_handler = interruption11; |
|
# endif |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGFABORT, &action, NULL) != 0) |
if (sigaction(SIGFABORT, &action, NULL) != 0) |
Line 467 rplinit(int argc, char *argv[], unsigned
|
Line 567 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption8; |
action.sa_sigaction = interruption8; |
|
# else |
|
action.sa_handler = interruption8; |
|
# endif |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGURG, &action, NULL) != 0) |
if (sigaction(SIGURG, &action, NULL) != 0) |
Line 487 rplinit(int argc, char *argv[], unsigned
|
Line 591 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption7; |
action.sa_sigaction = interruption7; |
|
# else |
|
action.sa_handler = interruption7; |
|
# endif |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGPIPE, &action, NULL) != 0) |
if (sigaction(SIGPIPE, &action, NULL) != 0) |
Line 507 rplinit(int argc, char *argv[], unsigned
|
Line 615 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption6; |
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) |
if (sigaction(SIGINJECT, &action, NULL) != 0) |
{ |
{ |
Line 527 rplinit(int argc, char *argv[], unsigned
|
Line 639 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption9; |
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) |
if (sigaction(SIGABORT, &action, NULL) != 0) |
{ |
{ |
Line 547 rplinit(int argc, char *argv[], unsigned
|
Line 663 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption1; |
action.sa_sigaction = interruption1; |
|
# else |
|
action.sa_handler = interruption1; |
|
# endif |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGALRM, &action, NULL) != 0) |
if (sigaction(SIGALRM, &action, NULL) != 0) |
Line 567 rplinit(int argc, char *argv[], unsigned
|
Line 687 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption3; |
action.sa_sigaction = interruption3; |
|
# else |
|
action.sa_handler = interruption3; |
|
# endif |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
(*s_etat_processus).chemin_fichiers_temporaires = |
|
recherche_chemin_fichiers_temporaires(s_etat_processus); |
|
|
|
erreur = d_absence_erreur; |
erreur = d_absence_erreur; |
core = d_faux; |
core = d_faux; |
mode_interactif = d_faux; |
mode_interactif = d_faux; |
Line 1495 rplinit(int argc, char *argv[], unsigned
|
Line 1616 rplinit(int argc, char *argv[], unsigned
|
|
|
if (option_n == d_vrai) |
if (option_n == d_vrai) |
{ |
{ |
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption10; |
action.sa_sigaction = interruption10; |
|
# else |
|
action.sa_handler = interruption10; |
|
# endif |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGHUP, &action, NULL) != 0) |
if (sigaction(SIGHUP, &action, NULL) != 0) |
Line 1716 rplinit(int argc, char *argv[], unsigned
|
Line 1841 rplinit(int argc, char *argv[], unsigned
|
(*s_etat_processus).autorisation_empilement_programme = 'N'; |
(*s_etat_processus).autorisation_empilement_programme = 'N'; |
(*s_etat_processus).requete_arret = 'N'; |
(*s_etat_processus).requete_arret = 'N'; |
(*s_etat_processus).evaluation_forcee = 'N'; |
(*s_etat_processus).evaluation_forcee = 'N'; |
|
(*s_etat_processus).recherche_type = 'N'; |
|
|
(*s_etat_processus).constante_symbolique = 'N'; |
(*s_etat_processus).constante_symbolique = 'N'; |
(*s_etat_processus).traitement_symbolique = 'N'; |
(*s_etat_processus).traitement_symbolique = 'N'; |
Line 1861 rplinit(int argc, char *argv[], unsigned
|
Line 1987 rplinit(int argc, char *argv[], unsigned
|
} |
} |
|
|
(*s_etat_processus).at_exit = NULL; |
(*s_etat_processus).at_exit = NULL; |
|
(*s_etat_processus).at_poke = NULL; |
|
(*s_etat_processus).traitement_at_poke = 'N'; |
|
|
(*s_etat_processus).pointeurs_caracteres = NULL; |
(*s_etat_processus).pointeurs_caracteres = NULL; |
(*s_etat_processus).arbre_instructions = NULL; |
(*s_etat_processus).arbre_instructions = NULL; |
Line 1869 rplinit(int argc, char *argv[], unsigned
|
Line 1997 rplinit(int argc, char *argv[], unsigned
|
(*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; |
|
(*s_etat_processus).var_volatile_processus_racine = -1; |
(*s_etat_processus).var_volatile_traitement_retarde_stop = 0; |
(*s_etat_processus).var_volatile_traitement_retarde_stop = 0; |
(*s_etat_processus).var_volatile_alarme = 0; |
(*s_etat_processus).var_volatile_alarme = 0; |
(*s_etat_processus).var_volatile_requete_arret = 0; |
(*s_etat_processus).var_volatile_requete_arret = 0; |
Line 1897 rplinit(int argc, char *argv[], unsigned
|
Line 2026 rplinit(int argc, char *argv[], unsigned
|
} |
} |
|
|
if (((*s_etat_processus).instruction_derniere_erreur = |
if (((*s_etat_processus).instruction_derniere_erreur = |
malloc(2 * sizeof(unsigned char))) == NULL) |
malloc(sizeof(unsigned char))) == NULL) |
{ |
{ |
erreur = d_es_allocation_memoire; |
erreur = d_es_allocation_memoire; |
|
|
Line 1948 rplinit(int argc, char *argv[], unsigned
|
Line 2077 rplinit(int argc, char *argv[], unsigned
|
|
|
free((*s_etat_processus).instruction_courante); |
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; |
erreur = d_es_allocation_memoire; |
} |
} |
Line 2653 rplinit(int argc, char *argv[], unsigned
|
Line 2782 rplinit(int argc, char *argv[], unsigned
|
(*s_etat_processus).at_exit, 'E'); |
(*s_etat_processus).at_exit, 'E'); |
} |
} |
} |
} |
|
|
liberation(s_etat_processus, |
|
(*s_etat_processus).at_exit); |
|
} |
} |
|
|
|
liberation(s_etat_processus, (*s_etat_processus).at_exit); |
|
liberation(s_etat_processus, (*s_etat_processus).at_poke); |
|
|
if ((*s_etat_processus).generateur_aleatoire != NULL) |
if ((*s_etat_processus).generateur_aleatoire != NULL) |
{ |
{ |
liberation_generateur_aleatoire(s_etat_processus); |
liberation_generateur_aleatoire(s_etat_processus); |
Line 3399 rplinit(int argc, char *argv[], unsigned
|
Line 3528 rplinit(int argc, char *argv[], unsigned
|
l_element_courant = l_element_suivant; |
l_element_courant = l_element_suivant; |
} |
} |
|
|
free((*s_etat_processus).chemin_fichiers_temporaires); |
|
|
|
l_element_courant = (*s_etat_processus).s_marques; |
l_element_courant = (*s_etat_processus).s_marques; |
while(l_element_courant != NULL) |
while(l_element_courant != NULL) |
{ |
{ |
Line 3452 rplinit(int argc, char *argv[], unsigned
|
Line 3579 rplinit(int argc, char *argv[], unsigned
|
} |
} |
} |
} |
|
|
# ifndef Cygwin |
|
(*s_etat_processus).pile_signal.ss_flags = SS_DISABLE; |
|
sigaltstack(&((*s_etat_processus).pile_signal), NULL); |
|
free((*s_etat_processus).pile_signal.ss_sp); |
|
# endif |
|
|
|
closelog(); |
closelog(); |
|
|
pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes)); |
pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes)); |
Line 3467 rplinit(int argc, char *argv[], unsigned
|
Line 3588 rplinit(int argc, char *argv[], unsigned
|
retrait_thread(s_etat_processus); |
retrait_thread(s_etat_processus); |
|
|
pthread_mutex_destroy(&((*s_etat_processus).mutex)); |
pthread_mutex_destroy(&((*s_etat_processus).mutex)); |
|
pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation)); |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
sem_post(&((*s_etat_processus).semaphore_fork)); |
sem_post(&((*s_etat_processus).semaphore_fork)); |
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
Line 3493 rplinit(int argc, char *argv[], unsigned
|
Line 3616 rplinit(int argc, char *argv[], unsigned
|
sem_gestionnaires_signaux_atomique); |
sem_gestionnaires_signaux_atomique); |
# endif |
# endif |
|
|
|
# ifdef _BROKEN_SIGINFO |
|
destruction_fifos_signaux(s_etat_processus); |
|
# undef return |
|
# endif |
|
|
|
free((*s_etat_processus).chemin_fichiers_temporaires); |
free(s_etat_processus); |
free(s_etat_processus); |
|
|
# ifdef DEBUG_MEMOIRE |
# ifdef DEBUG_MEMOIRE |