version 1.162, 2015/01/05 13:12:41
|
version 1.183, 2016/03/22 17:12:14
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.19 |
RPL/2 (R) version 4.1.25 |
Copyright (C) 1989-2015 Dr. BERTRAND Joël |
Copyright (C) 1989-2016 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 123 rplinit(int argc, char *argv[], char *en
|
Line 123 rplinit(int argc, char *argv[], char *en
|
errno = 0; |
errno = 0; |
s_queue_signaux = NULL; |
s_queue_signaux = NULL; |
routine_recursive = 0; |
routine_recursive = 0; |
|
nombre_thread_surveillance_processus = 0; |
pid_processus_pere = getpid(); |
pid_processus_pere = getpid(); |
|
|
# ifdef DEBUG_MEMOIRE |
# ifdef DEBUG_MEMOIRE |
Line 132 rplinit(int argc, char *argv[], char *en
|
Line 133 rplinit(int argc, char *argv[], char *en
|
setvbuf(stdout, NULL, _IOLBF, 0); |
setvbuf(stdout, NULL, _IOLBF, 0); |
setvbuf(stderr, NULL, _IOLBF, 0); |
setvbuf(stderr, NULL, _IOLBF, 0); |
|
|
if ((s_etat_processus = malloc(sizeof(struct_processus))) == NULL) |
if ((s_etat_processus = sys_malloc(sizeof(struct_processus))) == NULL) |
|
{ |
|
erreur = d_es_allocation_memoire; |
|
|
|
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); |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = d_es; |
|
|
|
initialisation_allocateur_buffer(s_etat_processus); |
|
|
|
if ((*s_etat_processus).erreur_systeme != d_es) |
|
{ |
|
erreur = d_es_allocation_memoire; |
|
|
|
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 (initialisation_etat_processus_readline() != 0) |
{ |
{ |
erreur = d_es_allocation_memoire; |
erreur = d_es_allocation_memoire; |
|
|
Line 179 rplinit(int argc, char *argv[], char *en
|
Line 230 rplinit(int argc, char *argv[], char *en
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
if ((arg_exec = malloc((((size_t) argc) + 1) * sizeof(char *))) == NULL) |
if ((arg_exec = sys_malloc((((size_t) argc) + 1) * sizeof(char *))) == NULL) |
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
Line 198 rplinit(int argc, char *argv[], char *en
|
Line 249 rplinit(int argc, char *argv[], char *en
|
arg_exec[i] = argv[i]; |
arg_exec[i] = argv[i]; |
} |
} |
|
|
argv[argc] = NULL; |
arg_exec[argc] = NULL; |
|
|
initialisation_contexte_cas(s_etat_processus); |
initialisation_contexte_cas(s_etat_processus); |
|
|
Line 234 rplinit(int argc, char *argv[], char *en
|
Line 285 rplinit(int argc, char *argv[], char *en
|
pthread_mutexattr_destroy(&attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_init(&attributs_mutex); |
|
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
|
pthread_mutex_init(&((*s_etat_processus).mutex_allocation_buffer), |
|
&attributs_mutex); |
|
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
|
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE); |
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE); |
pthread_mutex_init(&mutex_sections_critiques, &attributs_mutex); |
pthread_mutex_init(&mutex_sections_critiques, &attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
Line 243 rplinit(int argc, char *argv[], char *en
|
Line 300 rplinit(int argc, char *argv[], char *en
|
pthread_mutex_init(&mutex_liste_variables_partagees, &attributs_mutex); |
pthread_mutex_init(&mutex_liste_variables_partagees, &attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
|
pthread_mutexattr_init(&attributs_mutex); |
|
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE); |
|
pthread_mutex_init(&mutex_liste_threads, &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 379 rplinit(int argc, char *argv[], char *en
|
Line 441 rplinit(int argc, char *argv[], char *en
|
|
|
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("+++Copyright (C) 1989 à 2014, 2015 BERTRAND Joël\n"); |
printf("+++Copyright (C) 1989 à 2015, 2016 BERTRAND Joël\n"); |
} |
} |
else |
else |
{ |
{ |
printf("+++Copyright (C) 1989 to 2014, 2015 BERTRAND Joel\n"); |
printf("+++Copyright (C) 1989 to 2015, 2016 BERTRAND Joel\n"); |
} |
} |
} |
} |
|
|
Line 453 rplinit(int argc, char *argv[], char *en
|
Line 515 rplinit(int argc, char *argv[], char *en
|
} |
} |
# endif |
# endif |
|
|
if (lancement_thread_signaux(s_etat_processus) != d_absence_erreur) |
|
{ |
|
# ifndef SEMAPHORES_NOMMES |
|
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 |
|
|
|
liberation_contexte_cas(s_etat_processus); |
|
destruction_queue_signaux(s_etat_processus); |
|
|
|
# ifdef HAVE_STACK_OVERFLOW_RECOVERY |
|
stackoverflow_deinstall_handler(); |
|
# endif |
|
|
|
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); |
|
} |
|
|
|
action.sa_handler = interruption1; |
action.sa_handler = interruption1; |
action.sa_flags = 0; |
action.sa_flags = 0; |
|
|
Line 1965 rplinit(int argc, char *argv[], char *en
|
Line 1994 rplinit(int argc, char *argv[], char *en
|
} |
} |
|
|
if (((*s_etat_processus).definitions_chainees = |
if (((*s_etat_processus).definitions_chainees = |
compactage((*s_etat_processus) |
compactage(s_etat_processus, |
.definitions_chainees)) == NULL) |
(*s_etat_processus).definitions_chainees)) |
|
== NULL) |
{ |
{ |
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
sem_post(&((*s_etat_processus).semaphore_fork)); |
sem_post(&((*s_etat_processus).semaphore_fork)); |
Line 4928 rplinit(int argc, char *argv[], char *en
|
Line 4958 rplinit(int argc, char *argv[], char *en
|
(*(*((struct_processus_fils *) |
(*(*((struct_processus_fils *) |
(*(*((struct_liste_chainee *) |
(*(*((struct_liste_chainee *) |
l_element_courant)).donnee).objet)) |
l_element_courant)).donnee).objet)) |
.thread).pid, rpl_sigurg); |
.thread).pid, rpl_sigurg, d_faux); |
} |
} |
else |
else |
{ |
{ |
Line 4939 rplinit(int argc, char *argv[], char *en
|
Line 4969 rplinit(int argc, char *argv[], char *en
|
(*(*((struct_processus_fils *) |
(*(*((struct_processus_fils *) |
(*(*((struct_liste_chainee *) |
(*(*((struct_liste_chainee *) |
l_element_courant)).donnee).objet)) |
l_element_courant)).donnee).objet)) |
.thread).pid, rpl_sigabort); |
.thread).pid, rpl_sigabort, d_faux); |
} |
} |
else |
else |
{ |
{ |
Line 4947 rplinit(int argc, char *argv[], char *en
|
Line 4977 rplinit(int argc, char *argv[], char *en
|
(*(*((struct_processus_fils *) |
(*(*((struct_processus_fils *) |
(*(*((struct_liste_chainee *) |
(*(*((struct_liste_chainee *) |
l_element_courant)).donnee).objet)) |
l_element_courant)).donnee).objet)) |
.thread).pid, rpl_sigstop); |
.thread).pid, rpl_sigstop, d_faux); |
} |
} |
} |
} |
} |
} |
Line 5344 rplinit(int argc, char *argv[], char *en
|
Line 5374 rplinit(int argc, char *argv[], char *en
|
{ |
{ |
if ((*resultats) != NULL) |
if ((*resultats) != NULL) |
{ |
{ |
free((*resultats)); |
sys_free((*resultats)); |
|
|
if (((*resultats) = malloc(((size_t) |
if (((*resultats) = sys_malloc(((size_t) |
((*s_etat_processus) |
((*s_etat_processus) |
.hauteur_pile_operationnelle + 1)) |
.hauteur_pile_operationnelle + 1)) |
* sizeof(unsigned char **))) != NULL) |
* sizeof(unsigned char **))) != NULL) |
Line 5700 rplinit(int argc, char *argv[], char *en
|
Line 5730 rplinit(int argc, char *argv[], char *en
|
erreur = d_erreur; |
erreur = d_erreur; |
} |
} |
|
|
free(arg_exec); |
liberation_etat_processus_readline(); |
arret_thread_signaux(s_etat_processus); |
|
free(s_etat_processus); |
liberation_allocateur_buffer(s_etat_processus); |
|
pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation_buffer)); |
|
|
|
sys_free(s_etat_processus); |
|
sys_free(arg_exec); |
|
|
# ifdef DEBUG_MEMOIRE |
# ifdef DEBUG_MEMOIRE |
debug_memoire_verification(); |
debug_memoire_verification(); |
Line 5828 controle_integrite(struct_processus *s_e
|
Line 5862 controle_integrite(struct_processus *s_e
|
|
|
|
|
unsigned char * |
unsigned char * |
date_compilation() |
date_compilation(struct_processus *s_etat_processus) |
{ |
{ |
unsigned char *date; |
unsigned char *date; |
|
|