![]() ![]() | ![]() |
1.1 bertrand 1: /*
2: ================================================================================
1.200 ! bertrand 3: RPL/2 (R) version 4.1.28
1.192 bertrand 4: Copyright (C) 1989-2017 Dr. BERTRAND Joël
1.1 bertrand 5:
6: This file is part of RPL/2.
7:
8: RPL/2 is free software; you can redistribute it and/or modify it
9: under the terms of the CeCILL V2 License as published by the french
10: CEA, CNRS and INRIA.
11:
12: RPL/2 is distributed in the hope that it will be useful, but WITHOUT
13: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14: FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License
15: for more details.
16:
17: You should have received a copy of the CeCILL License
18: along with RPL/2. If not, write to info@cecill.info.
19: ================================================================================
20: */
21:
22:
23: #define MAIN_RPL
1.35 bertrand 24: #include "rpl-conv.h"
1.1 bertrand 25:
1.156 bertrand 26: // Bug de gcc à partir de gcc 4.6 (bug 48544)
27: #pragma GCC diagnostic push
28: #pragma GCC diagnostic ignored "-Wclobbered"
29:
1.37 bertrand 30:
1.1 bertrand 31: /*
32: ================================================================================
33: Programme principal
34: ================================================================================
35: */
36:
37: int
1.101 bertrand 38: rplinit(int argc, char *argv[], char *envp[],
39: unsigned char ***resultats, char *rpl_home)
1.1 bertrand 40: {
1.35 bertrand 41: # include "copyright-conv.h"
42: # include "licence-conv.h"
1.1 bertrand 43:
1.104 bertrand 44: char **arg_exec;
45:
1.97 bertrand 46: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1.94 bertrand 47: char pile_signaux[SIGSTKSZ];
1.97 bertrand 48: # endif
1.94 bertrand 49:
1.103 bertrand 50: # define RPL_PATH_MAX 1024
51: char repertoire_initial[RPL_PATH_MAX];
52:
1.1 bertrand 53: file *f_source;
54:
55: int erreur_historique;
56: int option_P;
57:
1.136 bertrand 58: integer8 i;
59:
1.1 bertrand 60: logical1 core;
61: logical1 debug;
62: logical1 erreur_fichier;
63: logical1 existence;
64: logical1 mode_interactif;
65: logical1 option_a;
66: logical1 option_A;
67: logical1 option_c;
68: logical1 option_d;
69: logical1 option_D;
70: logical1 option_h;
71: logical1 option_i;
72: logical1 option_l;
73: logical1 option_n;
74: logical1 option_p;
75: logical1 option_s;
76: logical1 option_S;
77: logical1 option_t;
78: logical1 option_v;
79: logical1 ouverture;
80:
81: pthread_mutexattr_t attributs_mutex;
82:
83: ssize_t longueur_ecriture;
84:
85: struct_objet *s_objet;
86:
87: struct_processus *s_etat_processus;
88:
1.195 bertrand 89: struct_liste_chainee *l_bibliotheques;
90: struct_liste_chainee *l_bibliotheque_courante;
91: struct_liste_chainee *l_nouvelle_bibliotheque;
92:
1.127 bertrand 93: struct_liste_variables_partagees *l_element_partage_courant;
94: struct_liste_variables_partagees *l_element_partage_suivant;
95:
1.121 bertrand 96: struct_liste_variables_statiques *l_element_statique_courant;
97: struct_liste_variables_statiques *l_element_statique_suivant;
98:
1.127 bertrand 99: struct_arbre_variables_partagees *s_arbre_variables_partagees;
100: struct_liste_variables_partagees *l_liste_variables_partagees;
101:
1.1 bertrand 102: struct sigaction action;
103: struct sigaction registre;
104:
105: struct timespec attente;
106:
107: unsigned char *arguments;
108: unsigned char drapeau_encart;
109: unsigned char *type_debug;
110: unsigned char *home;
111: unsigned char *langue;
112: unsigned char *message;
113: unsigned char *nom_fichier_temporaire;
114: unsigned char option;
115: unsigned char presence_definition;
116: unsigned char *ptr;
117: unsigned char *tampon;
118:
119: unsigned long unite_fichier;
120:
121: void *l_element_courant;
122: void *l_element_suivant;
123:
124: volatile int erreur;
125: volatile unsigned char traitement_fichier_temporaire;
126:
1.37 bertrand 127: errno = 0;
1.85 bertrand 128: s_queue_signaux = NULL;
1.94 bertrand 129: routine_recursive = 0;
1.183 bertrand 130: nombre_thread_surveillance_processus = 0;
1.82 bertrand 131: pid_processus_pere = getpid();
1.37 bertrand 132:
1.186 bertrand 133: # ifdef DEBUG_PROC
134: __proc = 0;
135: # endif
136:
1.27 bertrand 137: # ifdef DEBUG_MEMOIRE
138: debug_memoire_initialisation();
139: # endif
140:
1.1 bertrand 141: setvbuf(stdout, NULL, _IOLBF, 0);
142: setvbuf(stderr, NULL, _IOLBF, 0);
143:
1.165 bertrand 144: if ((s_etat_processus = sys_malloc(sizeof(struct_processus))) == NULL)
1.1 bertrand 145: {
146: erreur = d_es_allocation_memoire;
147:
1.17 bertrand 148: if ((langue = getenv("LANG")) != NULL)
1.1 bertrand 149: {
1.17 bertrand 150: if (strncmp(langue, "fr", 2) == 0)
151: {
152: uprintf("+++Système : Mémoire insuffisante\n");
153: }
154: else
155: {
156: uprintf("+++System : Not enough memory\n");
157: }
1.1 bertrand 158: }
159: else
160: {
1.17 bertrand 161: uprintf("+++System : Not enough memory\n");
1.1 bertrand 162: }
163:
164: return(EXIT_FAILURE);
165: }
166:
1.164 bertrand 167: (*s_etat_processus).erreur_systeme = d_es;
168:
169: initialisation_allocateur_buffer(s_etat_processus);
170:
171: if ((*s_etat_processus).erreur_systeme != d_es)
172: {
173: erreur = d_es_allocation_memoire;
174:
175: if ((langue = getenv("LANG")) != NULL)
176: {
177: if (strncmp(langue, "fr", 2) == 0)
178: {
179: uprintf("+++Système : Mémoire insuffisante\n");
180: }
181: else
182: {
183: uprintf("+++System : Not enough memory\n");
184: }
185: }
186: else
187: {
188: uprintf("+++System : Not enough memory\n");
189: }
190:
191: return(EXIT_FAILURE);
192: }
193:
1.165 bertrand 194: if (initialisation_etat_processus_readline() != 0)
195: {
196: erreur = d_es_allocation_memoire;
197:
198: if ((langue = getenv("LANG")) != NULL)
199: {
200: if (strncmp(langue, "fr", 2) == 0)
201: {
202: uprintf("+++Système : Mémoire insuffisante\n");
203: }
204: else
205: {
206: uprintf("+++System : Not enough memory\n");
207: }
208: }
209: else
210: {
211: uprintf("+++System : Not enough memory\n");
212: }
213:
214: return(EXIT_FAILURE);
215: }
216:
1.17 bertrand 217: if ((langue = getenv("LANG")) != NULL)
218: {
219: (*s_etat_processus).langue = (strncmp(langue, "fr", 2) == 0)
220: ? 'F' : 'E';
221: }
222: else
223: {
224: (*s_etat_processus).langue = 'E';
225: }
226:
1.103 bertrand 227: if (getcwd(repertoire_initial, RPL_PATH_MAX) == NULL)
228: {
1.124 bertrand 229: if ((*s_etat_processus).langue == 'F')
1.103 bertrand 230: {
1.124 bertrand 231: uprintf("+++Système : Mémoire insuffisante\n");
1.103 bertrand 232: }
233: else
234: {
235: uprintf("+++System : Not enough memory\n");
236: }
237:
238: return(EXIT_FAILURE);
239: }
240:
1.167 bertrand 241: if ((arg_exec = sys_malloc((((size_t) argc) + 1) * sizeof(char *))) == NULL)
1.104 bertrand 242: {
1.124 bertrand 243: if ((*s_etat_processus).langue == 'F')
1.104 bertrand 244: {
1.124 bertrand 245: uprintf("+++Système : Mémoire insuffisante\n");
1.104 bertrand 246: }
247: else
248: {
249: uprintf("+++System : Not enough memory\n");
250: }
251:
252: return(EXIT_FAILURE);
253: }
254:
1.136 bertrand 255: for(i = 0; i < argc; i++)
1.104 bertrand 256: {
257: arg_exec[i] = argv[i];
258: }
259:
1.167 bertrand 260: arg_exec[argc] = NULL;
1.104 bertrand 261:
1.76 bertrand 262: initialisation_contexte_cas(s_etat_processus);
263:
1.1 bertrand 264: (*s_etat_processus).exception = d_ep;
265: (*s_etat_processus).erreur_systeme = d_es;
266: (*s_etat_processus).erreur_execution = d_ex;
267:
1.102 bertrand 268: (*s_etat_processus).requete_redemarrage = d_faux;
1.11 bertrand 269: (*s_etat_processus).rpl_home = rpl_home;
270:
1.1 bertrand 271: pthread_mutexattr_init(&attributs_mutex);
272: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
1.146 bertrand 273: pthread_mutex_init(&((*s_etat_processus).mutex_pile_processus),
274: &attributs_mutex);
1.1 bertrand 275: pthread_mutexattr_destroy(&attributs_mutex);
276:
1.30 bertrand 277: pthread_mutexattr_init(&attributs_mutex);
278: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
1.145 bertrand 279: pthread_mutex_init(&((*s_etat_processus).mutex_interruptions),
280: &attributs_mutex);
281: pthread_mutexattr_destroy(&attributs_mutex);
282:
283: pthread_mutexattr_init(&attributs_mutex);
284: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
1.146 bertrand 285: pthread_mutex_init(&((*s_etat_processus).mutex_signaux),
286: &attributs_mutex);
287: pthread_mutexattr_destroy(&attributs_mutex);
288:
289: pthread_mutexattr_init(&attributs_mutex);
290: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
1.30 bertrand 291: pthread_mutex_init(&((*s_etat_processus).mutex_allocation),
292: &attributs_mutex);
293: pthread_mutexattr_destroy(&attributs_mutex);
294:
1.117 bertrand 295: pthread_mutexattr_init(&attributs_mutex);
1.166 bertrand 296: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
297: pthread_mutex_init(&((*s_etat_processus).mutex_allocation_buffer),
298: &attributs_mutex);
299: pthread_mutexattr_destroy(&attributs_mutex);
300:
301: pthread_mutexattr_init(&attributs_mutex);
1.117 bertrand 302: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
303: pthread_mutex_init(&mutex_sections_critiques, &attributs_mutex);
304: pthread_mutexattr_destroy(&attributs_mutex);
305:
1.128 bertrand 306: pthread_mutexattr_init(&attributs_mutex);
307: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
308: pthread_mutex_init(&mutex_liste_variables_partagees, &attributs_mutex);
309: pthread_mutexattr_destroy(&attributs_mutex);
310:
1.173 bertrand 311: pthread_mutexattr_init(&attributs_mutex);
312: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_RECURSIVE);
313: pthread_mutex_init(&mutex_liste_threads, &attributs_mutex);
314: pthread_mutexattr_destroy(&attributs_mutex);
315:
1.91 bertrand 316: # ifndef SEMAPHORES_NOMMES
317: sem_init(&((*s_etat_processus).semaphore_fork), 0, 0);
318: # else
319: if (((*s_etat_processus).semaphore_fork = sem_init3(0, getpid(),
1.92 bertrand 320: pthread_self(), SEM_FORK)) == SEM_FAILED)
1.91 bertrand 321: {
1.155 bertrand 322: liberation_contexte_cas(s_etat_processus);
1.124 bertrand 323:
1.91 bertrand 324: if ((*s_etat_processus).langue == 'F')
325: {
326: uprintf("+++Système : Mémoire insuffisante\n");
327: }
328: else
329: {
330: uprintf("+++System : Not enough memory\n");
331: }
332:
333: return(EXIT_FAILURE);
334: }
335: # endif
1.1 bertrand 336:
337: pthread_mutexattr_init(&attributs_mutex);
338: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
339: pthread_mutex_init(&((*s_etat_processus).protection_liste_mutexes),
340: &attributs_mutex);
341: pthread_mutexattr_destroy(&attributs_mutex);
342:
1.40 bertrand 343: (*s_etat_processus).chemin_fichiers_temporaires =
344: recherche_chemin_fichiers_temporaires(s_etat_processus);
345:
1.43 bertrand 346: insertion_thread(s_etat_processus, d_vrai);
1.83 bertrand 347: creation_queue_signaux(s_etat_processus);
1.40 bertrand 348:
1.124 bertrand 349: if ((*s_etat_processus).erreur_systeme != d_es)
350: {
351: # ifndef SEMAPHORES_NOMMES
352: sem_post(&((*s_etat_processus).semaphore_fork));
353: sem_destroy(&((*s_etat_processus).semaphore_fork));
354: # else
355: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 356: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 357: pthread_self(), SEM_FORK);
358: # endif
359:
360: liberation_contexte_cas(s_etat_processus);
361:
362: if ((*s_etat_processus).langue == 'F')
363: {
364: uprintf("+++Système : Mémoire insuffisante\n");
365: }
366: else
367: {
368: uprintf("+++System : Not enough memory\n");
369: }
370:
371: return(EXIT_FAILURE);
372: }
373:
1.123 bertrand 374: if (d_forced_locale == 0)
375: {
376: localisation_courante(s_etat_processus);
377: }
378: else
1.42 bertrand 379: {
1.124 bertrand 380: if (((*s_etat_processus).localisation = malloc((strlen(d_locale)
381: + 1) * sizeof(unsigned char))) == NULL)
1.42 bertrand 382: {
1.148 bertrand 383: # ifndef SEMAPHORES_NOMMES
384: sem_post(&((*s_etat_processus).semaphore_fork));
385: sem_destroy(&((*s_etat_processus).semaphore_fork));
386: # else
387: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 388: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.148 bertrand 389: pthread_self(), SEM_FORK);
390: # endif
391:
392: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 393: destruction_queue_signaux(s_etat_processus);
1.148 bertrand 394:
1.124 bertrand 395: if ((*s_etat_processus).langue == 'F')
396: {
397: uprintf("+++Système : Mémoire insuffisante\n");
398: }
399: else
1.42 bertrand 400: {
1.124 bertrand 401: uprintf("+++System : Not enough memory\n");
1.42 bertrand 402: }
403:
1.124 bertrand 404: return(EXIT_FAILURE);
1.42 bertrand 405: }
1.124 bertrand 406:
407: strcpy((*s_etat_processus).localisation, d_locale);
1.42 bertrand 408: }
1.40 bertrand 409:
1.17 bertrand 410: (*s_etat_processus).erreur_systeme = d_es;
1.1 bertrand 411:
1.17 bertrand 412: if ((*s_etat_processus).localisation == NULL)
1.1 bertrand 413: {
1.17 bertrand 414: if (((*s_etat_processus).localisation = malloc((strlen(d_locale) + 1) *
415: sizeof(unsigned char))) == NULL)
1.1 bertrand 416: {
1.124 bertrand 417: # ifndef SEMAPHORES_NOMMES
418: sem_post(&((*s_etat_processus).semaphore_fork));
419: sem_destroy(&((*s_etat_processus).semaphore_fork));
420: # else
421: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 422: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 423: pthread_self(), SEM_FORK);
424: # endif
425:
426: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 427: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 428:
1.17 bertrand 429: if ((*s_etat_processus).langue == 'F')
430: {
431: uprintf("+++Système : Mémoire insuffisante\n");
432: }
433: else
434: {
435: uprintf("+++System : Not enough memory\n");
436: }
437:
438: return(EXIT_FAILURE);
1.1 bertrand 439: }
440:
1.17 bertrand 441: strcpy((*s_etat_processus).localisation, d_locale);
1.1 bertrand 442: }
443:
1.150 bertrand 444: if (resultats == NULL) // Appel direct
445: {
446: printf("+++RPL/2 (R) version %s (%s)\n", d_version_rpl,
447: ((*s_etat_processus).langue == 'F')
448: ? d_date_rpl : d_date_en_rpl);
1.1 bertrand 449:
1.150 bertrand 450: if ((*s_etat_processus).langue == 'F')
451: {
1.191 bertrand 452: printf("+++Copyright (C) 1989 à 2016, 2017 BERTRAND Joël\n");
1.150 bertrand 453: }
454: else
455: {
1.191 bertrand 456: printf("+++Copyright (C) 1989 to 2016, 2017 BERTRAND Joel\n");
1.150 bertrand 457: }
1.1 bertrand 458: }
459:
460: if (getenv("HOME") != NULL)
461: {
462: home = getenv("HOME");
463: }
464: else if ((getenv("USER") != NULL) && (getpwnam(getenv("USER")) != NULL))
465: {
466: home = getpwnam(getenv("USER"))->pw_dir;
467: }
468: else if ((getenv("LOGNAME") != NULL) && (getpwnam(getenv("LOGNAME"))
469: != NULL))
470: {
471: home = getpwnam(getenv("LOGNAME"))->pw_dir;
472: }
473: else if ((getuid() != ((uid_t) -1)) && (getpwuid(getuid()) != NULL))
474: {
475: home = getpwuid(getuid())->pw_dir;
476: }
477: else
478: {
479: home = "";
480: }
481:
1.94 bertrand 482: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
483: if (stackoverflow_install_handler(interruption_depassement_pile,
484: pile_signaux, sizeof(pile_signaux)) != 0)
485: {
1.124 bertrand 486: # ifndef SEMAPHORES_NOMMES
487: sem_post(&((*s_etat_processus).semaphore_fork));
488: sem_destroy(&((*s_etat_processus).semaphore_fork));
489: # else
490: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 491: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 492: pthread_self(), SEM_FORK);
493: # endif
494:
495: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 496: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 497:
1.94 bertrand 498: erreur = d_es_signal;
1.1 bertrand 499:
1.94 bertrand 500: if ((*s_etat_processus).langue == 'F')
501: {
502: printf("+++Système : Initialisation de la pile alternative "
503: "impossible\n");
504: }
505: else
506: {
507: printf("+++System : Initialization of alternate "
508: "stack failed\n");
509: }
1.1 bertrand 510:
1.94 bertrand 511: return(EXIT_FAILURE);
1.1 bertrand 512: }
1.94 bertrand 513: # else
1.1 bertrand 514: if ((*s_etat_processus).langue == 'F')
515: {
1.94 bertrand 516: printf("+++Attention : Le système ne supporte pas de pile "
517: "alternative\n");
1.1 bertrand 518: }
519: else
520: {
1.94 bertrand 521: printf("+++Warning : Operating system does not support alternate "
522: "stack\n");
1.1 bertrand 523: }
1.9 bertrand 524: # endif
1.1 bertrand 525:
1.40 bertrand 526: action.sa_handler = interruption1;
1.94 bertrand 527: action.sa_flags = 0;
1.1 bertrand 528:
529: if (sigaction(SIGINT, &action, NULL) != 0)
530: {
1.124 bertrand 531: # ifndef SEMAPHORES_NOMMES
532: sem_post(&((*s_etat_processus).semaphore_fork));
533: sem_destroy(&((*s_etat_processus).semaphore_fork));
534: # else
535: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 536: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 537: pthread_self(), SEM_FORK);
538: # endif
539:
540: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 541: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 542:
543: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
544: stackoverflow_deinstall_handler();
545: # endif
546:
1.1 bertrand 547: erreur = d_es_signal;
548:
549: if ((*s_etat_processus).langue == 'F')
550: {
551: printf("+++Système : Initialisation des signaux POSIX "
552: "impossible\n");
553: }
554: else
555: {
556: printf("+++System : Initialization of POSIX signals failed\n");
557: }
558:
559: return(EXIT_FAILURE);
560: }
561:
1.81 bertrand 562: signal_test = SIGTEST;
1.133 bertrand 563: raise(SIGINT);
1.81 bertrand 564:
1.115 bertrand 565: attente.tv_sec = 0;
566: attente.tv_nsec = 1000000;
567:
568: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
569: {
570: nanosleep(&attente, NULL);
571: }
572:
1.81 bertrand 573: if (signal_test != SIGINT)
574: {
1.124 bertrand 575: # ifndef SEMAPHORES_NOMMES
576: sem_post(&((*s_etat_processus).semaphore_fork));
577: sem_destroy(&((*s_etat_processus).semaphore_fork));
578: # else
579: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 580: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 581: pthread_self(), SEM_FORK);
582: # endif
583:
584: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 585: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 586:
587: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
588: stackoverflow_deinstall_handler();
589: # endif
590:
1.81 bertrand 591: erreur = d_es_signal;
592:
593: if ((*s_etat_processus).langue == 'F')
594: {
595: printf("+++Système : Initialisation des signaux POSIX "
596: "impossible\n");
597: }
598: else
599: {
600: printf("+++System : Initialization of POSIX signals failed\n");
601: }
602:
603: return(EXIT_FAILURE);
604: }
605:
1.54 bertrand 606: if (sigaction(SIGTERM, &action, NULL) != 0)
607: {
1.124 bertrand 608: # ifndef SEMAPHORES_NOMMES
609: sem_post(&((*s_etat_processus).semaphore_fork));
610: sem_destroy(&((*s_etat_processus).semaphore_fork));
611: # else
612: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 613: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 614: pthread_self(), SEM_FORK);
615: # endif
616:
617: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 618: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 619:
620: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
621: stackoverflow_deinstall_handler();
622: # endif
623:
1.54 bertrand 624: erreur = d_es_signal;
625:
626: if ((*s_etat_processus).langue == 'F')
627: {
628: printf("+++Système : Initialisation des signaux POSIX "
629: "impossible\n");
630: }
631: else
632: {
633: printf("+++System : Initialization of POSIX signals failed\n");
634: }
635:
636: return(EXIT_FAILURE);
637: }
638:
1.81 bertrand 639: signal_test = SIGTEST;
1.133 bertrand 640: raise(SIGTERM);
1.81 bertrand 641:
1.115 bertrand 642: attente.tv_sec = 0;
643: attente.tv_nsec = 1000000;
644:
645: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
646: {
647: nanosleep(&attente, NULL);
648: }
649:
1.81 bertrand 650: if (signal_test != SIGTERM)
651: {
1.124 bertrand 652: # ifndef SEMAPHORES_NOMMES
653: sem_post(&((*s_etat_processus).semaphore_fork));
654: sem_destroy(&((*s_etat_processus).semaphore_fork));
655: # else
656: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 657: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 658: pthread_self(), SEM_FORK);
659: # endif
660:
661: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 662: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 663:
664: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
665: stackoverflow_deinstall_handler();
666: # endif
667:
1.81 bertrand 668: erreur = d_es_signal;
669:
670: if ((*s_etat_processus).langue == 'F')
671: {
672: printf("+++Système : Initialisation des signaux POSIX "
673: "impossible\n");
674: }
675: else
676: {
677: printf("+++System : Initialization of POSIX signals failed\n");
678: }
679:
680: return(EXIT_FAILURE);
681: }
682:
1.186 bertrand 683: if (sigaction(SIGUSR2, &action, NULL) != 0)
1.106 bertrand 684: {
1.124 bertrand 685: # ifndef SEMAPHORES_NOMMES
686: sem_post(&((*s_etat_processus).semaphore_fork));
687: sem_destroy(&((*s_etat_processus).semaphore_fork));
688: # else
689: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 690: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 691: pthread_self(), SEM_FORK);
692: # endif
693:
694: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 695: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 696:
697: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
698: stackoverflow_deinstall_handler();
699: # endif
700:
1.106 bertrand 701: erreur = d_es_signal;
702:
703: if ((*s_etat_processus).langue == 'F')
704: {
705: printf("+++Système : Initialisation des signaux POSIX "
706: "impossible\n");
707: }
708: else
709: {
710: printf("+++System : Initialization of POSIX signals failed\n");
711: }
712:
713: return(EXIT_FAILURE);
714: }
715:
716: signal_test = SIGTEST;
1.186 bertrand 717: raise(SIGUSR2);
1.106 bertrand 718:
1.115 bertrand 719: attente.tv_sec = 0;
720: attente.tv_nsec = 1000000;
721:
722: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
723: {
724: nanosleep(&attente, NULL);
725: }
726:
1.186 bertrand 727: if (signal_test != SIGUSR2)
1.106 bertrand 728: {
1.124 bertrand 729: # ifndef SEMAPHORES_NOMMES
730: sem_post(&((*s_etat_processus).semaphore_fork));
731: sem_destroy(&((*s_etat_processus).semaphore_fork));
732: # else
733: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 734: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 735: pthread_self(), SEM_FORK);
736: # endif
737:
738: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 739: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 740:
741: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
742: stackoverflow_deinstall_handler();
743: # endif
744:
1.106 bertrand 745: erreur = d_es_signal;
746:
747: if ((*s_etat_processus).langue == 'F')
748: {
749: printf("+++Système : Initialisation des signaux POSIX "
750: "impossible\n");
751: }
752: else
753: {
754: printf("+++System : Initialization of POSIX signals failed\n");
755: }
756:
757: return(EXIT_FAILURE);
758: }
759:
1.40 bertrand 760: action.sa_handler = interruption2;
1.94 bertrand 761: action.sa_flags = 0;
1.1 bertrand 762:
763: if (sigaction(SIGTSTP, &action, NULL) != 0)
764: {
1.124 bertrand 765: # ifndef SEMAPHORES_NOMMES
766: sem_post(&((*s_etat_processus).semaphore_fork));
767: sem_destroy(&((*s_etat_processus).semaphore_fork));
768: # else
769: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 770: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 771: pthread_self(), SEM_FORK);
772: # endif
773:
774: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 775: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 776:
777: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
778: stackoverflow_deinstall_handler();
779: # endif
780:
1.1 bertrand 781: if ((*s_etat_processus).langue == 'F')
782: {
783: printf("+++Système : Initialisation des signaux POSIX "
784: "impossible\n");
785: }
786: else
787: {
788: printf("+++System : Initialization of POSIX signals failed\n");
789: }
790:
791: return(EXIT_FAILURE);
792: }
793:
1.81 bertrand 794: signal_test = SIGTEST;
1.133 bertrand 795: raise(SIGTSTP);
1.81 bertrand 796:
1.115 bertrand 797: attente.tv_sec = 0;
798: attente.tv_nsec = 1000000;
799:
800: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
801: {
802: nanosleep(&attente, NULL);
803: }
804:
1.81 bertrand 805: if (signal_test != SIGTSTP)
806: {
1.124 bertrand 807: # ifndef SEMAPHORES_NOMMES
808: sem_post(&((*s_etat_processus).semaphore_fork));
809: sem_destroy(&((*s_etat_processus).semaphore_fork));
810: # else
811: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 812: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 813: pthread_self(), SEM_FORK);
814: # endif
815:
816: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 817: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 818:
819: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
820: stackoverflow_deinstall_handler();
821: # endif
822:
1.81 bertrand 823: erreur = d_es_signal;
824:
825: if ((*s_etat_processus).langue == 'F')
826: {
827: printf("+++Système : Initialisation des signaux POSIX "
828: "impossible\n");
829: }
830: else
831: {
832: printf("+++System : Initialization of POSIX signals failed\n");
833: }
834:
835: return(EXIT_FAILURE);
836: }
837:
1.40 bertrand 838: action.sa_handler = interruption5;
1.94 bertrand 839: action.sa_flags = 0;
1.1 bertrand 840:
841: if (sigaction(SIGPIPE, &action, NULL) != 0)
842: {
1.124 bertrand 843: # ifndef SEMAPHORES_NOMMES
844: sem_post(&((*s_etat_processus).semaphore_fork));
845: sem_destroy(&((*s_etat_processus).semaphore_fork));
846: # else
847: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 848: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 849: pthread_self(), SEM_FORK);
850: # endif
851:
852: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 853: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 854:
855: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
856: stackoverflow_deinstall_handler();
857: # endif
858:
1.1 bertrand 859: erreur = d_es_signal;
860:
861: if ((*s_etat_processus).langue == 'F')
862: {
863: printf("+++Système : Initialisation des signaux POSIX "
864: "impossible\n");
865: }
866: else
867: {
868: printf("+++System : Initialization of POSIX signals failed\n");
869: }
870:
871: return(EXIT_FAILURE);
872: }
873:
1.81 bertrand 874: signal_test = SIGTEST;
1.133 bertrand 875: raise(SIGPIPE);
1.81 bertrand 876:
1.115 bertrand 877: attente.tv_sec = 0;
878: attente.tv_nsec = 1000000;
879:
880: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
881: {
882: nanosleep(&attente, NULL);
883: }
884:
1.81 bertrand 885: if (signal_test != SIGPIPE)
886: {
1.124 bertrand 887: # ifndef SEMAPHORES_NOMMES
888: sem_post(&((*s_etat_processus).semaphore_fork));
889: sem_destroy(&((*s_etat_processus).semaphore_fork));
890: # else
891: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 892: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 893: pthread_self(), SEM_FORK);
894: # endif
895:
896: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 897: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 898:
899: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
900: stackoverflow_deinstall_handler();
901: # endif
902:
1.81 bertrand 903: erreur = d_es_signal;
904:
905: if ((*s_etat_processus).langue == 'F')
906: {
907: printf("+++Système : Initialisation des signaux POSIX "
908: "impossible\n");
909: }
910: else
911: {
912: printf("+++System : Initialization of POSIX signals failed\n");
913: }
914:
915: return(EXIT_FAILURE);
916: }
917:
1.40 bertrand 918: action.sa_handler = interruption1;
1.94 bertrand 919: action.sa_flags = 0;
1.1 bertrand 920:
1.94 bertrand 921: if (sigaction(SIGUSR1, &action, NULL) != 0)
1.1 bertrand 922: {
1.124 bertrand 923: # ifndef SEMAPHORES_NOMMES
924: sem_post(&((*s_etat_processus).semaphore_fork));
925: sem_destroy(&((*s_etat_processus).semaphore_fork));
926: # else
927: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 928: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 929: pthread_self(), SEM_FORK);
930: # endif
931:
932: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 933: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 934:
935: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
936: stackoverflow_deinstall_handler();
937: # endif
938:
1.1 bertrand 939: erreur = d_es_signal;
940:
941: if ((*s_etat_processus).langue == 'F')
942: {
943: printf("+++Système : Initialisation des signaux POSIX "
944: "impossible\n");
945: }
946: else
947: {
948: printf("+++System : Initialization of POSIX signals failed\n");
949: }
950:
951: return(EXIT_FAILURE);
952: }
953:
1.81 bertrand 954: signal_test = SIGTEST;
1.133 bertrand 955: raise(SIGUSR1);
1.81 bertrand 956:
1.115 bertrand 957: attente.tv_sec = 0;
958: attente.tv_nsec = 1000000;
959:
960: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
961: {
962: nanosleep(&attente, NULL);
963: }
964:
1.94 bertrand 965: if (signal_test != SIGUSR1)
1.81 bertrand 966: {
1.124 bertrand 967: # ifndef SEMAPHORES_NOMMES
968: sem_post(&((*s_etat_processus).semaphore_fork));
969: sem_destroy(&((*s_etat_processus).semaphore_fork));
970: # else
971: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 972: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(),
1.124 bertrand 973: pthread_self(), SEM_FORK);
974: # endif
975:
976: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 977: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 978:
979: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
980: stackoverflow_deinstall_handler();
981: # endif
982:
1.81 bertrand 983: erreur = d_es_signal;
984:
985: if ((*s_etat_processus).langue == 'F')
986: {
987: printf("+++Système : Initialisation des signaux POSIX "
988: "impossible\n");
989: }
990: else
991: {
992: printf("+++System : Initialization of POSIX signals failed\n");
993: }
994:
995: return(EXIT_FAILURE);
996: }
997:
1.82 bertrand 998: signal_test = SIGTEST + 1;
1.1 bertrand 999:
1.13 bertrand 1000: erreur = d_absence_erreur;
1.1 bertrand 1001: core = d_faux;
1002: mode_interactif = d_faux;
1003: (*s_etat_processus).nom_fichier_source = NULL;
1004: (*s_etat_processus).definitions_chainees = NULL;
1005: (*s_etat_processus).type_debug = 0;
1006: traitement_fichier_temporaire = 'N';
1007: option = ' ';
1008: drapeau_encart = 'Y';
1009: debug = d_faux;
1010: arguments = NULL;
1.195 bertrand 1011: l_bibliotheques = NULL;
1.1 bertrand 1012:
1013: (*s_etat_processus).s_fichiers = NULL;
1014: (*s_etat_processus).s_sockets = NULL;
1015: (*s_etat_processus).s_connecteurs_sql = NULL;
1016:
1017: setlogmask(LOG_MASK(LOG_NOTICE));
1018: openlog(argv[0], LOG_ODELAY | LOG_PID, LOG_USER);
1019:
1020: if (argc == 1)
1021: {
1.13 bertrand 1022: erreur = d_erreur;
1.1 bertrand 1023: informations(s_etat_processus);
1024: }
1025: else
1026: {
1027: presence_definition = 'N';
1028: (*s_etat_processus).debug = d_faux;
1029: (*s_etat_processus).lancement_interactif = d_faux;
1030:
1031: option_a = d_faux;
1032: option_A = d_faux;
1033: option_c = d_faux;
1034: option_d = d_faux;
1035: option_D = d_faux;
1036: option_h = d_faux;
1037: option_i = d_faux;
1038: option_l = d_faux;
1039: option_n = d_faux;
1040: option_p = d_faux;
1041: option_P = 0;
1042: option_s = d_faux;
1043: option_S = d_faux;
1044: option_t = d_faux;
1045: option_v = d_faux;
1046:
1.86 bertrand 1047: // Lorsque le programme est appelé depuis un shebang, argv[0] contient
1048: // le chemin du programme et argv[1] tous les arguments.
1049: // argv[2] contient quant à lui le nom du script RPL/2.
1050: //
1051: // Exemple :
1052: // argv[0] : /usr/local/bin/rpl
1053: // argv[1] : -csdp -t 800
1054: // argv[2] : ./on_exit.rpl
1055:
1.1 bertrand 1056: while((--argc) > 0)
1057: {
1058: if ((*(++argv))[0] == '-')
1059: {
1060: while((option = *(++argv[0])) != '\0')
1061: {
1062: switch(option)
1063: {
1064: case 'a' :
1065: {
1066: if (option_a == d_vrai)
1067: {
1.124 bertrand 1068: # ifndef SEMAPHORES_NOMMES
1069: sem_post(&((*s_etat_processus).semaphore_fork));
1070: sem_destroy(&((*s_etat_processus)
1071: .semaphore_fork));
1072: # else
1073: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1074: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1075: getpid(), pthread_self(), SEM_FORK);
1076: # endif
1077:
1078: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1079: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1080:
1081: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1082: stackoverflow_deinstall_handler();
1083: # endif
1084:
1.1 bertrand 1085: if ((*s_etat_processus).langue == 'F')
1086: {
1087: printf("+++Erreur : option -a présente "
1088: "plus d'une fois\n");
1089: }
1090: else
1091: {
1092: printf("+++Error : more than one -a "
1093: "on command line");
1094: }
1095:
1096: return(EXIT_FAILURE);
1097: }
1098:
1099: option_a = d_vrai;
1100: break;
1101: }
1102:
1103: case 'A' :
1104: {
1105: if (option_A == d_vrai)
1106: {
1.124 bertrand 1107: # ifndef SEMAPHORES_NOMMES
1108: sem_post(&((*s_etat_processus).semaphore_fork));
1109: sem_destroy(&((*s_etat_processus)
1110: .semaphore_fork));
1111: # else
1112: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1113: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1114: getpid(), pthread_self(), SEM_FORK);
1115: # endif
1116:
1117: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1118: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1119:
1120: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1121: stackoverflow_deinstall_handler();
1122: # endif
1123:
1.1 bertrand 1124: if ((*s_etat_processus).langue == 'F')
1125: {
1126: printf("+++Erreur : option -A présente "
1127: "plus d'une fois\n");
1128: }
1129: else
1130: {
1131: printf("+++Error : more than one -A "
1132: "on command line");
1133: }
1134:
1135: return(EXIT_FAILURE);
1136: }
1137:
1138: option_A = d_vrai;
1139:
1140: while(*(++argv[0]) == ' ');
1141: argv[0]--;
1142:
1143: if ((*(++argv[0])) != '\0')
1144: {
1145: if ((arguments = malloc((strlen(argv[0]) + 7) *
1146: sizeof(unsigned char))) == NULL)
1147: {
1.124 bertrand 1148: # ifndef SEMAPHORES_NOMMES
1149: sem_post(&((*s_etat_processus)
1150: .semaphore_fork));
1151: sem_destroy(&((*s_etat_processus)
1152: .semaphore_fork));
1153: # else
1154: sem_post((*s_etat_processus)
1155: .semaphore_fork);
1156: sem_destroy3((*s_etat_processus)
1.155 bertrand 1157: .semaphore_fork, getpid(),
1.124 bertrand 1158: pthread_self(), SEM_FORK);
1159: # endif
1160:
1161: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1162: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1163:
1164: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1165: stackoverflow_deinstall_handler();
1166: # endif
1167:
1.1 bertrand 1168: if ((*s_etat_processus).langue == 'F')
1169: {
1170: printf("+++Système : Mémoire "
1171: "insuffisante\n");
1172: }
1173: else
1174: {
1175: printf("+++System : Not enough "
1176: "memory\n");
1177: }
1178:
1179: return(EXIT_FAILURE);
1180: }
1181:
1182: ptr = arguments;
1183: (*ptr) = d_code_fin_chaine;
1184: strcat(ptr, "<< ");
1185: ptr += 3;
1186:
1187: while(*(argv[0]) != '\0')
1188: {
1189: *(ptr++) = *(argv[0]++);
1190: }
1191:
1192: (*ptr) = '\0';
1193:
1194: strcat(arguments, " >>");
1195: argv[0]--;
1196: }
1197: else if ((--argc) > 0)
1198: {
1199: argv++;
1200:
1201: if ((arguments = malloc((strlen(argv[0]) + 7) *
1202: sizeof(unsigned char))) == NULL)
1203: {
1.124 bertrand 1204: # ifndef SEMAPHORES_NOMMES
1205: sem_post(&((*s_etat_processus)
1206: .semaphore_fork));
1207: sem_destroy(&((*s_etat_processus)
1208: .semaphore_fork));
1209: # else
1210: sem_post((*s_etat_processus)
1211: .semaphore_fork);
1212: sem_destroy3((*s_etat_processus)
1.155 bertrand 1213: .semaphore_fork, getpid(),
1.124 bertrand 1214: pthread_self(), SEM_FORK);
1215: # endif
1216:
1217: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1218: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1219:
1220: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1221: stackoverflow_deinstall_handler();
1222: # endif
1223:
1.1 bertrand 1224: if ((*s_etat_processus).langue == 'F')
1225: {
1226: printf("+++Système : Mémoire "
1227: "insuffisante\n");
1228: }
1229: else
1230: {
1231: printf("+++System : Not enough "
1232: "memory\n");
1233: }
1234:
1235: return(EXIT_FAILURE);
1236: }
1237:
1238: ptr = arguments;
1239: (*ptr) = d_code_fin_chaine;
1240: strcat(ptr, "<< ");
1241: ptr += 3;
1242:
1243: while(*(argv[0]) != '\0')
1244: {
1245: *(ptr++) = *(argv[0]++);
1246: }
1247:
1248: (*ptr) = '\0';
1249:
1250: strcat(arguments, " >>");
1251: argv[0]--;
1252: }
1253: else
1254: {
1.124 bertrand 1255: # ifndef SEMAPHORES_NOMMES
1256: sem_post(&((*s_etat_processus).semaphore_fork));
1257: sem_destroy(&((*s_etat_processus)
1258: .semaphore_fork));
1259: # else
1260: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1261: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1262: getpid(), pthread_self(), SEM_FORK);
1263: # endif
1264:
1265: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1266: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1267:
1268: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1269: stackoverflow_deinstall_handler();
1270: # endif
1271:
1.1 bertrand 1272: if ((*s_etat_processus).langue == 'F')
1273: {
1274: printf("+++Erreur : Aucune donnée "
1275: "spécifié après l'option -A\n");
1276: }
1277: else
1278: {
1279: printf("+++Error : Data required after "
1280: "-A option\n");
1281: }
1282:
1283: return(EXIT_FAILURE);
1284: }
1285:
1286: break;
1287: }
1288:
1289: case 'c' :
1290: {
1291: if (option_c == d_vrai)
1292: {
1.124 bertrand 1293: # ifndef SEMAPHORES_NOMMES
1294: sem_post(&((*s_etat_processus).semaphore_fork));
1295: sem_destroy(&((*s_etat_processus)
1296: .semaphore_fork));
1297: # else
1298: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1299: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1300: getpid(), pthread_self(), SEM_FORK);
1301: # endif
1302:
1303: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1304: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1305:
1306: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1307: stackoverflow_deinstall_handler();
1308: # endif
1309:
1.1 bertrand 1310: if ((*s_etat_processus).langue == 'F')
1311: {
1312: printf("+++Erreur : option -c présente "
1313: "plus d'une fois\n");
1314: }
1315: else
1316: {
1317: printf("+++Error : more than one -c "
1318: "on command line");
1319: }
1320:
1321: return(EXIT_FAILURE);
1322: }
1323:
1324: option_c = d_vrai;
1325: core = d_vrai;
1326: break;
1327: }
1328:
1329: case 'd' :
1330: {
1331: if (option_d == d_vrai)
1332: {
1.124 bertrand 1333: # ifndef SEMAPHORES_NOMMES
1334: sem_post(&((*s_etat_processus).semaphore_fork));
1335: sem_destroy(&((*s_etat_processus)
1336: .semaphore_fork));
1337: # else
1338: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1339: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1340: getpid(), pthread_self(), SEM_FORK);
1341: # endif
1342:
1343: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1344: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1345:
1346: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1347: stackoverflow_deinstall_handler();
1348: # endif
1349:
1.1 bertrand 1350: if ((*s_etat_processus).langue == 'F')
1351: {
1352: printf("+++Erreur : option -d présente "
1353: "plus d'une fois\n");
1354: }
1355: else
1356: {
1357: printf("+++Error : more than one -d "
1358: "on command line");
1359: }
1360:
1361: return(EXIT_FAILURE);
1362: }
1363:
1364: option_d = d_vrai;
1365: debug = d_vrai;
1366: break;
1367: }
1368:
1369: case 'D' :
1370: {
1371: if (option_D == d_vrai)
1372: {
1.124 bertrand 1373: # ifndef SEMAPHORES_NOMMES
1374: sem_post(&((*s_etat_processus).semaphore_fork));
1375: sem_destroy(&((*s_etat_processus)
1376: .semaphore_fork));
1377: # else
1378: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1379: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1380: getpid(), pthread_self(), SEM_FORK);
1381: # endif
1382:
1383: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1384: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1385:
1386: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1387: stackoverflow_deinstall_handler();
1388: # endif
1389:
1.1 bertrand 1390: if ((*s_etat_processus).langue == 'F')
1391: {
1392: printf("+++Erreur : option -D présente "
1393: "plus d'une fois\n");
1394: }
1395: else
1396: {
1397: printf("+++Error : more than one -D "
1398: "on command line");
1399: }
1400:
1401: return(EXIT_FAILURE);
1402: }
1403:
1404: option_D = d_vrai;
1405: break;
1406: }
1407:
1408: case 'h' :
1409: {
1410: if (option_h == d_vrai)
1411: {
1.124 bertrand 1412: # ifndef SEMAPHORES_NOMMES
1413: sem_post(&((*s_etat_processus).semaphore_fork));
1414: sem_destroy(&((*s_etat_processus)
1415: .semaphore_fork));
1416: # else
1417: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1418: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1419: getpid(), pthread_self(), SEM_FORK);
1420: # endif
1421:
1422: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1423: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1424:
1425: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1426: stackoverflow_deinstall_handler();
1427: # endif
1428:
1.1 bertrand 1429: if ((*s_etat_processus).langue == 'F')
1430: {
1431: printf("+++Erreur : option -h présente "
1432: "plus d'une fois\n");
1433: }
1434: else
1435: {
1436: printf("+++Error : more than one -h "
1437: "on command line");
1438: }
1439:
1440: return(EXIT_FAILURE);
1441: }
1442:
1443: option_h = d_vrai;
1444: informations(s_etat_processus);
1445: break;
1446: }
1447:
1448: case 'i' :
1449: {
1450: if (option_i == d_vrai)
1451: {
1.124 bertrand 1452: # ifndef SEMAPHORES_NOMMES
1453: sem_post(&((*s_etat_processus).semaphore_fork));
1454: sem_destroy(&((*s_etat_processus)
1455: .semaphore_fork));
1456: # else
1457: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1458: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1459: getpid(), pthread_self(), SEM_FORK);
1460: # endif
1461:
1462: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1463: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1464:
1465: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1466: stackoverflow_deinstall_handler();
1467: # endif
1468:
1.1 bertrand 1469: if ((*s_etat_processus).langue == 'F')
1470: {
1471: printf("+++Erreur : option -i présente "
1472: "plus d'une fois\n");
1473: }
1474: else
1475: {
1476: printf("+++Error : more than one -i "
1477: "on command line");
1478: }
1479:
1480: return(EXIT_FAILURE);
1481: }
1482: else if (option_S == d_vrai)
1483: {
1.124 bertrand 1484: # ifndef SEMAPHORES_NOMMES
1485: sem_post(&((*s_etat_processus).semaphore_fork));
1486: sem_destroy(&((*s_etat_processus)
1487: .semaphore_fork));
1488: # else
1489: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1490: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1491: getpid(), pthread_self(), SEM_FORK);
1492: # endif
1493:
1494: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1495: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1496:
1497: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1498: stackoverflow_deinstall_handler();
1499: # endif
1500:
1.1 bertrand 1501: if ((*s_etat_processus).langue == 'F')
1502: {
1503: printf("+++Erreur : options -i et -S "
1504: "incompatibles\n");
1505: }
1506: else
1507: {
1508: printf("+++Error : incompatible options -i "
1509: "and -S\n");
1510: }
1511:
1512: return(EXIT_FAILURE);
1513: }
1514: else if (option_p == d_vrai)
1515: {
1.124 bertrand 1516: # ifndef SEMAPHORES_NOMMES
1517: sem_post(&((*s_etat_processus).semaphore_fork));
1518: sem_destroy(&((*s_etat_processus)
1519: .semaphore_fork));
1520: # else
1521: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1522: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1523: getpid(), pthread_self(), SEM_FORK);
1524: # endif
1525:
1526: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1527: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1528:
1529: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1530: stackoverflow_deinstall_handler();
1531: # endif
1532:
1.1 bertrand 1533: if ((*s_etat_processus).langue == 'F')
1534: {
1535: printf("+++Erreur : options -i et -p "
1536: "incompatibles\n");
1537: }
1538: else
1539: {
1540: printf("+++Error : incompatible options -i "
1541: "and -p\n");
1542: }
1543:
1544: return(EXIT_FAILURE);
1545: }
1546:
1547: option_i = d_vrai;
1548: mode_interactif = d_vrai;
1549: presence_definition = 'O';
1550: break;
1551: }
1552:
1553: case 'l' :
1554: {
1555: if (option_l == d_vrai)
1556: {
1.124 bertrand 1557: # ifndef SEMAPHORES_NOMMES
1558: sem_post(&((*s_etat_processus).semaphore_fork));
1559: sem_destroy(&((*s_etat_processus)
1560: .semaphore_fork));
1561: # else
1562: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1563: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1564: getpid(), pthread_self(), SEM_FORK);
1565: # endif
1566:
1567: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1568: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1569:
1570: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1571: stackoverflow_deinstall_handler();
1572: # endif
1573:
1.1 bertrand 1574: if ((*s_etat_processus).langue == 'F')
1575: {
1576: printf("+++Erreur : option -l présente "
1577: "plus d'une fois\n");
1578: }
1579: else
1580: {
1581: printf("+++Error : more than one -l "
1582: "on command line");
1583: }
1584:
1585: return(EXIT_FAILURE);
1586: }
1587:
1588: option_l = d_vrai;
1589:
1590: if ((*s_etat_processus).langue == 'F')
1591: {
1592: printf("%s\n\n", CeCILL_fr);
1593: }
1594: else
1595: {
1596: printf("%s\n\n", CeCILL_en);
1597: }
1598:
1599: break;
1600: }
1601:
1.195 bertrand 1602: case 'm' :
1603: {
1604: while(*(++argv[0]) == ' ');
1605: argv[0]--;
1606:
1607: if ((*(++argv[0])) != '\0')
1608: {
1609: if ((l_nouvelle_bibliotheque = malloc(
1610: sizeof(struct_liste_chainee))) == NULL)
1611: {
1612: # ifndef SEMAPHORES_NOMMES
1613: sem_post(&((*s_etat_processus)
1614: .semaphore_fork));
1615: sem_destroy(&((*s_etat_processus)
1616: .semaphore_fork));
1617: # else
1618: sem_post((*s_etat_processus)
1619: .semaphore_fork);
1620: sem_destroy3((*s_etat_processus)
1621: .semaphore_fork, getpid(),
1622: pthread_self(), SEM_FORK);
1623: # endif
1624:
1625: liberation_contexte_cas(s_etat_processus);
1626: destruction_queue_signaux(s_etat_processus);
1627:
1628: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1629: stackoverflow_deinstall_handler();
1630: # endif
1631:
1632: if ((*s_etat_processus).langue == 'F')
1633: {
1634: printf("+++Système : Mémoire "
1635: "insuffisante\n");
1636: }
1637: else
1638: {
1639: printf("+++System : Not enough "
1640: "memory\n");
1641: }
1642:
1643: return(EXIT_FAILURE);
1644: }
1645:
1646: (*l_nouvelle_bibliotheque).suivant =
1647: l_bibliotheques;
1648:
1649: if (((*l_nouvelle_bibliotheque).donnee =
1650: allocation(s_etat_processus, CHN))
1651: == NULL)
1652: {
1653: # ifndef SEMAPHORES_NOMMES
1654: sem_post(&((*s_etat_processus)
1655: .semaphore_fork));
1656: sem_destroy(&((*s_etat_processus)
1657: .semaphore_fork));
1658: # else
1659: sem_post((*s_etat_processus)
1660: .semaphore_fork);
1661: sem_destroy3((*s_etat_processus)
1662: .semaphore_fork, getpid(),
1663: pthread_self(), SEM_FORK);
1664: # endif
1665:
1666: liberation_contexte_cas(s_etat_processus);
1667: destruction_queue_signaux(s_etat_processus);
1668:
1669: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1670: stackoverflow_deinstall_handler();
1671: # endif
1672:
1673: if ((*s_etat_processus).langue == 'F')
1674: {
1675: printf("+++Système : Mémoire "
1676: "insuffisante\n");
1677: }
1678: else
1679: {
1680: printf("+++System : Not enough "
1681: "memory\n");
1682: }
1683:
1684: return(EXIT_FAILURE);
1685: }
1686:
1687: if (((*(*l_nouvelle_bibliotheque).donnee)
1688: .objet = malloc((strlen(argv[0]) + 1) *
1689: sizeof(unsigned char))) == NULL)
1690: {
1691: # ifndef SEMAPHORES_NOMMES
1692: sem_post(&((*s_etat_processus)
1693: .semaphore_fork));
1694: sem_destroy(&((*s_etat_processus)
1695: .semaphore_fork));
1696: # else
1697: sem_post((*s_etat_processus)
1698: .semaphore_fork);
1699: sem_destroy3((*s_etat_processus)
1700: .semaphore_fork, getpid(),
1701: pthread_self(), SEM_FORK);
1702: # endif
1703:
1704: liberation_contexte_cas(s_etat_processus);
1705: destruction_queue_signaux(s_etat_processus);
1706:
1707: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1708: stackoverflow_deinstall_handler();
1709: # endif
1710:
1711: if ((*s_etat_processus).langue == 'F')
1712: {
1713: printf("+++Système : Mémoire "
1714: "insuffisante\n");
1715: }
1716: else
1717: {
1718: printf("+++System : Not enough "
1719: "memory\n");
1720: }
1721:
1722: return(EXIT_FAILURE);
1723: }
1724:
1725: strcpy((*(*l_nouvelle_bibliotheque).donnee)
1726: .objet, argv[0]);
1727: argv[0] += strlen((unsigned char *)
1728: (*(*l_nouvelle_bibliotheque).donnee)
1729: .objet) - 1;
1730:
1731: l_bibliotheques = l_nouvelle_bibliotheque;
1732: }
1733: else if ((--argc) > 0)
1734: {
1735: argv++;
1736:
1737: if ((l_nouvelle_bibliotheque = malloc(
1738: sizeof(struct_liste_chainee))) == NULL)
1739: {
1740: # ifndef SEMAPHORES_NOMMES
1741: sem_post(&((*s_etat_processus)
1742: .semaphore_fork));
1743: sem_destroy(&((*s_etat_processus)
1744: .semaphore_fork));
1745: # else
1746: sem_post((*s_etat_processus)
1747: .semaphore_fork);
1748: sem_destroy3((*s_etat_processus)
1749: .semaphore_fork, getpid(),
1750: pthread_self(), SEM_FORK);
1751: # endif
1752:
1753: liberation_contexte_cas(s_etat_processus);
1754: destruction_queue_signaux(s_etat_processus);
1755:
1756: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1757: stackoverflow_deinstall_handler();
1758: # endif
1759:
1760: if ((*s_etat_processus).langue == 'F')
1761: {
1762: printf("+++Système : Mémoire "
1763: "insuffisante\n");
1764: }
1765: else
1766: {
1767: printf("+++System : Not enough "
1768: "memory\n");
1769: }
1770:
1771: return(EXIT_FAILURE);
1772: }
1773:
1774: (*l_nouvelle_bibliotheque).suivant =
1775: l_bibliotheques;
1776:
1777: if (((*l_nouvelle_bibliotheque).donnee =
1778: allocation(s_etat_processus, CHN))
1779: == NULL)
1780: {
1781: # ifndef SEMAPHORES_NOMMES
1782: sem_post(&((*s_etat_processus)
1783: .semaphore_fork));
1784: sem_destroy(&((*s_etat_processus)
1785: .semaphore_fork));
1786: # else
1787: sem_post((*s_etat_processus)
1788: .semaphore_fork);
1789: sem_destroy3((*s_etat_processus)
1790: .semaphore_fork, getpid(),
1791: pthread_self(), SEM_FORK);
1792: # endif
1793:
1794: liberation_contexte_cas(s_etat_processus);
1795: destruction_queue_signaux(s_etat_processus);
1796:
1797: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1798: stackoverflow_deinstall_handler();
1799: # endif
1800:
1801: if ((*s_etat_processus).langue == 'F')
1802: {
1803: printf("+++Système : Mémoire "
1804: "insuffisante\n");
1805: }
1806: else
1807: {
1808: printf("+++System : Not enough "
1809: "memory\n");
1810: }
1811:
1812: return(EXIT_FAILURE);
1813: }
1814:
1815: if (((*(*l_nouvelle_bibliotheque).donnee)
1816: .objet = malloc((strlen(argv[0]) + 1) *
1817: sizeof(unsigned char))) == NULL)
1818: {
1819: # ifndef SEMAPHORES_NOMMES
1820: sem_post(&((*s_etat_processus)
1821: .semaphore_fork));
1822: sem_destroy(&((*s_etat_processus)
1823: .semaphore_fork));
1824: # else
1825: sem_post((*s_etat_processus)
1826: .semaphore_fork);
1827: sem_destroy3((*s_etat_processus)
1828: .semaphore_fork, getpid(),
1829: pthread_self(), SEM_FORK);
1830: # endif
1831:
1832: liberation_contexte_cas(s_etat_processus);
1833: destruction_queue_signaux(s_etat_processus);
1834:
1835: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1836: stackoverflow_deinstall_handler();
1837: # endif
1838:
1839: if ((*s_etat_processus).langue == 'F')
1840: {
1841: printf("+++Système : Mémoire "
1842: "insuffisante\n");
1843: }
1844: else
1845: {
1846: printf("+++System : Not enough "
1847: "memory\n");
1848: }
1849:
1850: return(EXIT_FAILURE);
1851: }
1852:
1853: strcpy((*(*l_nouvelle_bibliotheque).donnee)
1854: .objet, argv[0]);
1855: argv[0] += strlen((unsigned char *)
1856: (*(*l_nouvelle_bibliotheque).donnee)
1857: .objet) - 1;
1858:
1859: l_bibliotheques = l_nouvelle_bibliotheque;
1860: }
1861: else
1862: {
1863: # ifndef SEMAPHORES_NOMMES
1864: sem_post(&((*s_etat_processus).semaphore_fork));
1865: sem_destroy(&((*s_etat_processus)
1866: .semaphore_fork));
1867: # else
1868: sem_post((*s_etat_processus).semaphore_fork);
1869: sem_destroy3((*s_etat_processus).semaphore_fork,
1870: getpid(), pthread_self(), SEM_FORK);
1871: # endif
1872:
1873: liberation_contexte_cas(s_etat_processus);
1874: destruction_queue_signaux(s_etat_processus);
1875:
1876: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1877: stackoverflow_deinstall_handler();
1878: # endif
1879:
1880: if ((*s_etat_processus).langue == 'F')
1881: {
1882: printf("+++Erreur : Aucune bibliothèque "
1883: "spécifiée après l'option -A\n");
1884: }
1885: else
1886: {
1887: printf("+++Error : Library required after "
1888: "-m option\n");
1889: }
1890:
1891: return(EXIT_FAILURE);
1892: }
1893:
1894: break;
1895: }
1896:
1.1 bertrand 1897: case 'n' :
1898: {
1899: if (option_n == d_vrai)
1900: {
1.124 bertrand 1901: # ifndef SEMAPHORES_NOMMES
1902: sem_post(&((*s_etat_processus).semaphore_fork));
1903: sem_destroy(&((*s_etat_processus)
1904: .semaphore_fork));
1905: # else
1906: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1907: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1908: getpid(), pthread_self(), SEM_FORK);
1909: # endif
1910:
1911: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1912: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1913:
1914: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1915: stackoverflow_deinstall_handler();
1916: # endif
1917:
1.1 bertrand 1918: if ((*s_etat_processus).langue == 'F')
1919: {
1920: printf("+++Erreur : option -n présente "
1921: "plus d'une fois\n");
1922: }
1923: else
1924: {
1925: printf("+++Error : more than one -n "
1926: "on command line");
1927: }
1928:
1929: return(EXIT_FAILURE);
1930: }
1931:
1932: option_n = d_vrai;
1933:
1934: break;
1935: }
1936:
1937: case 'p' :
1938: {
1939: if (option_p == d_vrai)
1940: {
1.124 bertrand 1941: # ifndef SEMAPHORES_NOMMES
1942: sem_post(&((*s_etat_processus).semaphore_fork));
1943: sem_destroy(&((*s_etat_processus)
1944: .semaphore_fork));
1945: # else
1946: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1947: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1948: getpid(), pthread_self(), SEM_FORK);
1949: # endif
1950:
1951: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1952: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1953:
1954: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1955: stackoverflow_deinstall_handler();
1956: # endif
1957:
1.1 bertrand 1958: if ((*s_etat_processus).langue == 'F')
1959: {
1960: printf("+++Erreur : option -p présente "
1961: "plus d'une fois\n");
1962: }
1963: else
1964: {
1965: printf("+++Error : more than one -p "
1966: "on command line");
1967: }
1968:
1969: return(EXIT_FAILURE);
1970: }
1971: else if (option_i == d_vrai)
1972: {
1.124 bertrand 1973: # ifndef SEMAPHORES_NOMMES
1974: sem_post(&((*s_etat_processus).semaphore_fork));
1975: sem_destroy(&((*s_etat_processus)
1976: .semaphore_fork));
1977: # else
1978: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 1979: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 1980: getpid(), pthread_self(), SEM_FORK);
1981: # endif
1982:
1983: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 1984: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 1985:
1986: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
1987: stackoverflow_deinstall_handler();
1988: # endif
1989:
1.1 bertrand 1990: if ((*s_etat_processus).langue == 'F')
1991: {
1992: printf("+++Erreur : options -i et -p "
1993: "incompatibles\n");
1994: }
1995: else
1996: {
1997: printf("+++Error : incompatible options -i "
1998: "and -p\n");
1999: }
2000:
2001: return(EXIT_FAILURE);
2002: }
2003:
2004: option_p = d_vrai;
2005:
2006: break;
2007: }
2008:
2009: case 'P' :
2010: {
2011: if (option_P > 2)
2012: {
1.124 bertrand 2013: # ifndef SEMAPHORES_NOMMES
2014: sem_post(&((*s_etat_processus).semaphore_fork));
2015: sem_destroy(&((*s_etat_processus)
2016: .semaphore_fork));
2017: # else
2018: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2019: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2020: getpid(), pthread_self(), SEM_FORK);
2021: # endif
2022:
2023: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2024: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2025:
2026: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2027: stackoverflow_deinstall_handler();
2028: # endif
2029:
1.1 bertrand 2030: if ((*s_etat_processus).langue == 'F')
2031: {
2032: printf("+++Erreur : option -P présente "
2033: "plus de deux fois\n");
2034: }
2035: else
2036: {
2037: printf("+++Error : more than two -P "
2038: "on command line");
2039: }
2040:
2041: return(EXIT_FAILURE);
2042: }
2043:
2044: option_P++;
2045:
2046: break;
2047: }
2048:
2049: case 's' :
2050: {
2051: if (option_s == d_vrai)
2052: {
1.124 bertrand 2053: # ifndef SEMAPHORES_NOMMES
2054: sem_post(&((*s_etat_processus).semaphore_fork));
2055: sem_destroy(&((*s_etat_processus)
2056: .semaphore_fork));
2057: # else
2058: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2059: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2060: getpid(), pthread_self(), SEM_FORK);
2061: # endif
2062:
2063: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2064: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2065:
2066: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2067: stackoverflow_deinstall_handler();
2068: # endif
2069:
1.1 bertrand 2070: if ((*s_etat_processus).langue == 'F')
2071: {
2072: printf("+++Erreur : option -s présente "
2073: "plus d'une fois\n");
2074: }
2075: else
2076: {
2077: printf("+++Error : more than one -s "
2078: "on command line");
2079: }
2080:
2081: return(EXIT_FAILURE);
2082: }
2083:
2084: option_s = d_vrai;
2085: drapeau_encart = 'N';
2086: break;
2087: }
2088:
2089: case 'S' :
2090: {
2091: if (option_S == d_vrai)
2092: {
1.124 bertrand 2093: # ifndef SEMAPHORES_NOMMES
2094: sem_post(&((*s_etat_processus).semaphore_fork));
2095: sem_destroy(&((*s_etat_processus)
2096: .semaphore_fork));
2097: # else
2098: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2099: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2100: getpid(), pthread_self(), SEM_FORK);
2101: # endif
2102:
2103: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2104: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2105:
2106: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2107: stackoverflow_deinstall_handler();
2108: # endif
2109:
1.1 bertrand 2110: if ((*s_etat_processus).langue == 'F')
2111: {
2112: printf("+++Erreur : option -S présente "
2113: "plus d'une fois\n");
2114: }
2115: else
2116: {
2117: printf("+++Error : more than one -S "
2118: "on command line");
2119: }
2120:
2121: return(EXIT_FAILURE);
2122: }
2123: else if (option_i == d_vrai)
2124: {
1.124 bertrand 2125: # ifndef SEMAPHORES_NOMMES
2126: sem_post(&((*s_etat_processus).semaphore_fork));
2127: sem_destroy(&((*s_etat_processus)
2128: .semaphore_fork));
2129: # else
2130: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2131: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2132: getpid(), pthread_self(), SEM_FORK);
2133: # endif
2134:
2135: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2136: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2137:
2138: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2139: stackoverflow_deinstall_handler();
2140: # endif
2141:
1.1 bertrand 2142: if ((*s_etat_processus).langue == 'F')
2143: {
2144: printf("+++Erreur : options -i et -S "
2145: "incompatibles\n");
2146: }
2147: else
2148: {
2149: printf("+++Error : incompatible options -S "
2150: "and -i\n");
2151: }
2152:
2153: return(EXIT_FAILURE);
2154: }
2155:
2156: option_S = d_vrai;
2157:
2158: while(*(++argv[0]) == ' ');
2159: argv[0]--;
2160:
2161: if ((*(++argv[0])) != '\0')
2162: {
2163: if (((*s_etat_processus).definitions_chainees =
2164: malloc((strlen(argv[0]) + 1) *
2165: sizeof(unsigned char))) == NULL)
2166: {
1.124 bertrand 2167: # ifndef SEMAPHORES_NOMMES
2168: sem_post(&((*s_etat_processus)
2169: .semaphore_fork));
2170: sem_destroy(&((*s_etat_processus)
2171: .semaphore_fork));
2172: # else
2173: sem_post((*s_etat_processus)
2174: .semaphore_fork);
2175: sem_destroy3((*s_etat_processus)
1.155 bertrand 2176: .semaphore_fork, getpid(),
1.124 bertrand 2177: pthread_self(), SEM_FORK);
2178: # endif
2179:
2180: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2181: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2182:
2183: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2184: stackoverflow_deinstall_handler();
2185: # endif
2186:
1.1 bertrand 2187: if ((*s_etat_processus).langue == 'F')
2188: {
2189: printf("+++Système : Mémoire "
2190: "insuffisante\n");
2191: }
2192: else
2193: {
2194: printf("+++System : Not enough "
2195: "memory\n");
2196: }
2197:
2198: return(EXIT_FAILURE);
2199: }
2200:
2201: ptr = (*s_etat_processus).definitions_chainees;
2202:
2203: while(*(argv[0]) != '\0')
2204: {
2205: *(ptr++) = *(argv[0]++);
2206: }
2207:
2208: (*ptr) = '\0';
2209:
2210: argv[0]--;
2211: presence_definition = 'O';
2212: }
2213: else if ((--argc) > 0)
2214: {
2215: argv++;
2216:
2217: if (((*s_etat_processus).definitions_chainees =
2218: malloc((strlen(argv[0]) + 1) *
2219: sizeof(unsigned char))) == NULL)
2220: {
1.124 bertrand 2221: # ifndef SEMAPHORES_NOMMES
2222: sem_post(&((*s_etat_processus)
2223: .semaphore_fork));
2224: sem_destroy(&((*s_etat_processus)
2225: .semaphore_fork));
2226: # else
2227: sem_post((*s_etat_processus)
2228: .semaphore_fork);
2229: sem_destroy3((*s_etat_processus)
1.155 bertrand 2230: .semaphore_fork, getpid(),
1.124 bertrand 2231: pthread_self(), SEM_FORK);
2232: # endif
2233:
2234: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2235: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2236:
2237: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2238: stackoverflow_deinstall_handler();
2239: # endif
2240:
1.1 bertrand 2241: if ((*s_etat_processus).langue == 'F')
2242: {
2243: printf("+++Système : Mémoire "
2244: "insuffisante\n");
2245: }
2246: else
2247: {
2248: printf("+++System : Not enough "
2249: "memory\n");
2250: }
2251:
2252: return(EXIT_FAILURE);
2253: }
2254:
2255: ptr = (*s_etat_processus).definitions_chainees;
2256:
2257: while(*(argv[0]) != '\0')
2258: {
2259: *(ptr++) = *(argv[0]++);
2260: }
2261:
2262: (*ptr) = '\0';
2263:
2264: argv[0]--;
2265: presence_definition = 'O';
2266: }
2267: else
2268: {
1.124 bertrand 2269: # ifndef SEMAPHORES_NOMMES
2270: sem_post(&((*s_etat_processus).semaphore_fork));
2271: sem_destroy(&((*s_etat_processus)
2272: .semaphore_fork));
2273: # else
2274: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2275: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2276: getpid(), pthread_self(), SEM_FORK);
2277: # endif
2278:
2279: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2280: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2281:
2282: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2283: stackoverflow_deinstall_handler();
2284: # endif
2285:
1.1 bertrand 2286: if ((*s_etat_processus).langue == 'F')
2287: {
2288: printf("+++Erreur : Aucun script "
2289: "spécifié après l'option -S\n");
2290: }
2291: else
2292: {
2293: printf("+++Error : Script required after "
2294: "-S option\n");
2295: }
2296:
2297: return(EXIT_FAILURE);
2298: }
2299:
2300: if (((*s_etat_processus).definitions_chainees =
1.165 bertrand 2301: compactage(s_etat_processus,
2302: (*s_etat_processus).definitions_chainees))
2303: == NULL)
1.1 bertrand 2304: {
1.124 bertrand 2305: # ifndef SEMAPHORES_NOMMES
2306: sem_post(&((*s_etat_processus).semaphore_fork));
2307: sem_destroy(&((*s_etat_processus)
2308: .semaphore_fork));
2309: # else
2310: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2311: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2312: getpid(), pthread_self(), SEM_FORK);
2313: # endif
2314:
2315: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2316: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2317:
2318: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2319: stackoverflow_deinstall_handler();
2320: # endif
2321:
1.1 bertrand 2322: if ((*s_etat_processus).langue == 'F')
2323: {
2324: printf("+++Système : Mémoire "
2325: "insuffisante\n");
2326: }
2327: else
2328: {
2329: printf("+++System : Not enough "
2330: "memory\n");
2331: }
2332:
2333: return(EXIT_FAILURE);
2334: }
2335:
2336: (*s_etat_processus).longueur_definitions_chainees =
1.136 bertrand 2337: (integer8) strlen((*s_etat_processus)
1.1 bertrand 2338: .definitions_chainees);
2339:
2340: break;
2341: }
2342:
2343: case 't' :
2344: {
2345: if (option_t == d_vrai)
2346: {
1.124 bertrand 2347: # ifndef SEMAPHORES_NOMMES
2348: sem_post(&((*s_etat_processus).semaphore_fork));
2349: sem_destroy(&((*s_etat_processus)
2350: .semaphore_fork));
2351: # else
2352: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2353: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2354: getpid(), pthread_self(), SEM_FORK);
2355: # endif
2356:
2357: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2358: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2359:
2360: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2361: stackoverflow_deinstall_handler();
2362: # endif
2363:
1.1 bertrand 2364: if ((*s_etat_processus).langue == 'F')
2365: {
2366: printf("+++Erreur : option -t présente "
2367: "plus d'une fois\n");
2368: }
2369: else
2370: {
2371: printf("+++Error : more than one -t "
2372: "on command line");
2373: }
2374:
2375: return(EXIT_FAILURE);
2376: }
2377:
2378: option_t = d_vrai;
2379: (*s_etat_processus).debug = d_vrai;
2380:
2381: while(*(++argv[0]) == ' ');
2382: argv[0]--;
2383:
2384: if ((*(++argv[0])) != '\0')
2385: {
2386: if ((type_debug = malloc((strlen(argv[0]) + 1) *
2387: sizeof(unsigned char))) == NULL)
2388: {
1.124 bertrand 2389: # ifndef SEMAPHORES_NOMMES
2390: sem_post(&((*s_etat_processus)
2391: .semaphore_fork));
2392: sem_destroy(&((*s_etat_processus)
2393: .semaphore_fork));
2394: # else
2395: sem_post((*s_etat_processus)
2396: .semaphore_fork);
2397: sem_destroy3((*s_etat_processus)
1.155 bertrand 2398: .semaphore_fork, getpid(),
1.124 bertrand 2399: pthread_self(), SEM_FORK);
2400: # endif
2401:
2402: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2403: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2404:
2405: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2406: stackoverflow_deinstall_handler();
2407: # endif
2408:
1.1 bertrand 2409: if ((*s_etat_processus).langue == 'F')
2410: {
2411: printf("+++Système : Mémoire "
2412: "insuffisante\n");
2413: }
2414: else
2415: {
2416: printf("+++System : Not enough "
2417: "memory\n");
2418: }
2419:
2420: return(EXIT_FAILURE);
2421: }
2422:
2423: ptr = type_debug;
2424:
2425: while((*(argv[0]) != '\0') &&
2426: (*(argv[0]) != ' '))
2427: {
2428: *(ptr++) = *(argv[0]++);
2429: }
2430:
2431: (*ptr) = '\0';
2432:
2433: argv[0]--;
2434: }
2435: else if ((--argc) > 0)
2436: {
2437: argv++;
2438:
2439: if ((type_debug =
2440: malloc((strlen(argv[0]) + 1) *
2441: sizeof(unsigned char))) == NULL)
2442: {
1.124 bertrand 2443: # ifndef SEMAPHORES_NOMMES
2444: sem_post(&((*s_etat_processus)
2445: .semaphore_fork));
2446: sem_destroy(&((*s_etat_processus)
2447: .semaphore_fork));
2448: # else
2449: sem_post((*s_etat_processus)
2450: .semaphore_fork);
2451: sem_destroy3((*s_etat_processus)
1.155 bertrand 2452: .semaphore_fork, getpid(),
1.124 bertrand 2453: pthread_self(), SEM_FORK);
2454: # endif
2455:
2456: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2457: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2458:
2459: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2460: stackoverflow_deinstall_handler();
2461: # endif
2462:
1.1 bertrand 2463: if ((*s_etat_processus).langue == 'F')
2464: {
2465: printf("+++Système : Mémoire "
2466: "insuffisante\n");
2467: }
2468: else
2469: {
2470: printf("+++System : Not enough "
2471: "memory\n");
2472: }
2473:
2474: return(EXIT_FAILURE);
2475: }
2476:
2477: ptr = type_debug;
2478:
2479: while(*(argv[0]) != '\0')
2480: {
2481: *(ptr++) = *(argv[0]++);
2482: }
2483:
2484: (*ptr) = '\0';
2485:
2486: argv[0]--;
2487: }
2488: else
2489: {
1.124 bertrand 2490: # ifndef SEMAPHORES_NOMMES
2491: sem_post(&((*s_etat_processus).semaphore_fork));
2492: sem_destroy(&((*s_etat_processus)
2493: .semaphore_fork));
2494: # else
2495: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2496: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2497: getpid(), pthread_self(), SEM_FORK);
2498: # endif
2499:
2500: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2501: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2502:
2503: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2504: stackoverflow_deinstall_handler();
2505: # endif
2506:
1.1 bertrand 2507: if ((*s_etat_processus).langue == 'F')
2508: {
2509: printf("+++Erreur : Aucun niveau "
2510: "de débogage spécifié après "
2511: "l'option -t\n");
2512: }
2513: else
2514: {
2515: printf("+++Error : Debug level not "
2516: "specified after -t option\n");
2517: }
2518:
2519: return(EXIT_FAILURE);
2520: }
2521:
2522: ptr = type_debug;
2523:
2524: while(*ptr != '\0')
2525: {
2526: switch(*ptr)
2527: {
2528: case '0':
2529: case '1':
2530: case '2':
2531: case '3':
2532: case '4':
2533: case '5':
2534: case '6':
2535: case '7':
2536: case '8':
2537: case '9':
2538: case 'A':
2539: case 'B':
2540: case 'C':
2541: case 'D':
2542: case 'E':
2543: case 'F':
2544: {
2545: break;
2546: }
2547:
2548: default:
2549: {
1.124 bertrand 2550: # ifndef SEMAPHORES_NOMMES
2551: sem_post(&((*s_etat_processus)
2552: .semaphore_fork));
2553: sem_destroy(&((*s_etat_processus)
2554: .semaphore_fork));
2555: # else
2556: sem_post((*s_etat_processus)
2557: .semaphore_fork);
2558: sem_destroy3((*s_etat_processus)
1.155 bertrand 2559: .semaphore_fork, getpid(),
1.124 bertrand 2560: pthread_self(), SEM_FORK);
2561: # endif
2562:
2563: liberation_contexte_cas(
2564: s_etat_processus);
1.161 bertrand 2565: destruction_queue_signaux(
1.124 bertrand 2566: s_etat_processus);
2567:
2568: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2569: stackoverflow_deinstall_handler();
2570: # endif
2571:
1.1 bertrand 2572: if ((*s_etat_processus).langue == 'F')
2573: {
2574: printf("+++Erreur : Niveau "
2575: "de débogage non "
2576: "hexadécimal\n");
2577: }
2578: else
2579: {
2580: printf("+++Error : Debug level must"
2581: " be hexadecimal "
2582: "integer\n");
2583: }
2584:
2585: return(EXIT_FAILURE);
2586: }
2587: }
2588:
2589: ptr++;
2590: }
2591:
2592: if (sscanf(type_debug, "%llX",
2593: &((*s_etat_processus).type_debug)) != 1)
2594: {
1.124 bertrand 2595: # ifndef SEMAPHORES_NOMMES
2596: sem_post(&((*s_etat_processus).semaphore_fork));
2597: sem_destroy(&((*s_etat_processus)
2598: .semaphore_fork));
2599: # else
2600: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2601: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2602: getpid(), pthread_self(), SEM_FORK);
2603: # endif
2604:
2605: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2606: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2607:
2608: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2609: stackoverflow_deinstall_handler();
2610: # endif
2611:
1.1 bertrand 2612: if ((*s_etat_processus).langue == 'F')
2613: {
2614: printf("+++Erreur : Niveau "
2615: "de débogage non entier\n");
2616: }
2617: else
2618: {
2619: printf("+++Error : Debug level must"
2620: " be integer\n");
2621: }
2622:
2623: return(EXIT_FAILURE);
2624: }
2625:
1.17 bertrand 2626: free(type_debug);
1.1 bertrand 2627: break;
2628: }
2629:
2630: case 'v' :
2631: {
2632: if (option_v == d_vrai)
2633: {
1.124 bertrand 2634: # ifndef SEMAPHORES_NOMMES
2635: sem_post(&((*s_etat_processus).semaphore_fork));
2636: sem_destroy(&((*s_etat_processus)
2637: .semaphore_fork));
2638: # else
2639: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2640: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2641: getpid(), pthread_self(), SEM_FORK);
2642: # endif
2643:
2644: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2645: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2646:
2647: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2648: stackoverflow_deinstall_handler();
2649: # endif
2650:
1.1 bertrand 2651: if ((*s_etat_processus).langue == 'F')
2652: {
2653: printf("+++Erreur : option -v présente "
2654: "plus d'une fois\n");
2655: }
2656: else
2657: {
2658: printf("+++Error : more than one -v "
2659: "on command line");
2660: }
2661:
2662: return(EXIT_FAILURE);
2663: }
2664:
2665: option_v = d_vrai;
2666: printf("\n");
2667:
2668: if ((*s_etat_processus).langue == 'F')
2669: {
2670: printf(" Reverse Polish Lisp/2 version %s "
2671: "pour systèmes "
2672: "POSIX\n", d_version_rpl);
2673: printf(" Langage procédural de très haut "
2674: "niveau, semi-compilé, "
2675: "extensible,\n");
2676: printf(" destiné principalement aux "
2677: "calculs scientifiques et "
2678: "symboliques\n");
2679: printf("%s\n", copyright);
2680: }
2681: else
2682: {
2683: printf(" Reverse Polish Lisp/2 version %s "
2684: "for POSIX operating systems\n",
2685: d_version_rpl);
2686: printf(" Half-compiled, high-level "
2687: "procedural language,\n");
2688: printf(" mainly aiming at scientific "
2689: "calculations\n");
2690: printf("%s\n", copyright_anglais);
2691: }
2692:
2693: printf("\n");
2694: break;
2695: }
2696:
1.86 bertrand 2697: case '-':
2698: case ' ':
2699: {
2700: break;
2701: }
2702:
1.1 bertrand 2703: default :
2704: {
2705: if ((*s_etat_processus).langue == 'F')
2706: {
1.3 bertrand 2707: printf("+++Information : Option -%c inconnue\n",
1.1 bertrand 2708: option);
2709: }
2710: else
2711: {
1.3 bertrand 2712: printf("+++Warning : -%c option unknown\n",
1.1 bertrand 2713: option);
2714: }
2715:
2716: informations(s_etat_processus);
2717: break;
2718: }
2719: }
2720: }
2721: }
2722: else
2723: {
2724: if (presence_definition == 'O')
2725: {
2726: argc = 0;
2727:
2728: if ((*s_etat_processus).langue == 'F')
2729: {
2730: printf("+++Erreur : Plusieurs définitions\n");
2731: }
2732: else
2733: {
2734: printf("+++Error : More than one definition\n");
2735: }
2736:
1.13 bertrand 2737: erreur = d_erreur;
1.1 bertrand 2738: }
2739: else
2740: {
2741: (*s_etat_processus).nom_fichier_source = argv[0];
2742: presence_definition = 'O';
2743: }
2744: }
2745: }
2746:
1.94 bertrand 2747: /*
2748: * Dans le cas où le programme est appelé avec l'option -d,
2749: * on ne récupère par les signaux de violation d'accès. On
2750: * tente simplement la récupération des dépassements de pile.
2751: */
2752:
1.1 bertrand 2753: if (debug == d_faux)
2754: {
1.189 bertrand 2755: # ifdef HAVE_SIGSEGV_RECOVERY
1.94 bertrand 2756: if (sigsegv_install_handler(interruption_violation_access) != 0)
2757: {
1.124 bertrand 2758: # ifndef SEMAPHORES_NOMMES
2759: sem_post(&((*s_etat_processus).semaphore_fork));
2760: sem_destroy(&((*s_etat_processus)
2761: .semaphore_fork));
2762: # else
2763: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2764: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2765: getpid(), pthread_self(), SEM_FORK);
2766: # endif
2767:
2768: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2769: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2770:
2771: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2772: stackoverflow_deinstall_handler();
2773: # endif
2774:
1.94 bertrand 2775: erreur = d_es_signal;
2776:
2777: if ((*s_etat_processus).langue == 'F')
2778: {
2779: printf("+++Système : Initialisation de la pile alternative "
2780: "impossible\n");
2781: }
2782: else
2783: {
2784: printf("+++System : Initialization of alternate "
2785: "stack failed\n");
2786: }
2787:
2788: return(EXIT_FAILURE);
2789: }
2790: # else
1.82 bertrand 2791: action.sa_handler = interruption3;
1.94 bertrand 2792: action.sa_flags = 0;
1.82 bertrand 2793:
1.1 bertrand 2794: if (sigaction(SIGSEGV, &action, NULL) != 0)
2795: {
1.124 bertrand 2796: # ifndef SEMAPHORES_NOMMES
2797: sem_post(&((*s_etat_processus).semaphore_fork));
2798: sem_destroy(&((*s_etat_processus)
2799: .semaphore_fork));
2800: # else
2801: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2802: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2803: getpid(), pthread_self(), SEM_FORK);
2804: # endif
2805:
2806: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2807: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2808:
2809: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2810: stackoverflow_deinstall_handler();
2811: # endif
2812:
1.1 bertrand 2813: if ((*s_etat_processus).langue == 'F')
2814: {
2815: printf("+++Système : Initialisation des signaux POSIX "
2816: "impossible\n");
2817: }
2818: else
2819: {
2820: printf("+++System : Initialization of POSIX signals "
2821: "failed\n");
2822: }
2823:
2824: return(EXIT_FAILURE);
2825: }
2826:
1.94 bertrand 2827: signal_test = SIGTEST;
1.133 bertrand 2828: raise(SIGSEGV);
1.94 bertrand 2829:
1.115 bertrand 2830: attente.tv_sec = 0;
2831: attente.tv_nsec = 1000000;
2832:
2833: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
2834: {
2835: nanosleep(&attente, NULL);
2836: }
2837:
1.94 bertrand 2838: if (signal_test != SIGSEGV)
2839: {
1.124 bertrand 2840: # ifndef SEMAPHORES_NOMMES
2841: sem_post(&((*s_etat_processus).semaphore_fork));
2842: sem_destroy(&((*s_etat_processus)
2843: .semaphore_fork));
2844: # else
2845: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2846: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2847: getpid(), pthread_self(), SEM_FORK);
2848: # endif
2849:
2850: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2851: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2852:
2853: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2854: stackoverflow_deinstall_handler();
2855: # endif
2856:
1.94 bertrand 2857: erreur = d_es_signal;
2858:
2859: if ((*s_etat_processus).langue == 'F')
2860: {
2861: printf("+++Système : Initialisation des signaux POSIX "
2862: "impossible\n");
2863: }
2864: else
2865: {
2866: printf("+++System : Initialization of POSIX signals "
2867: "failed\n");
2868: }
2869:
2870: return(EXIT_FAILURE);
2871: }
2872: # endif
2873:
1.115 bertrand 2874: action.sa_handler = interruption3;
2875: action.sa_flags = 0;
2876:
1.1 bertrand 2877: if (sigaction(SIGBUS, &action, NULL) != 0)
2878: {
1.124 bertrand 2879: # ifndef SEMAPHORES_NOMMES
2880: sem_post(&((*s_etat_processus).semaphore_fork));
2881: sem_destroy(&((*s_etat_processus)
2882: .semaphore_fork));
2883: # else
2884: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2885: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2886: getpid(), pthread_self(), SEM_FORK);
2887: # endif
2888:
2889: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2890: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2891:
2892: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2893: stackoverflow_deinstall_handler();
2894: # endif
2895:
2896: # ifdef HAVE_SIGSEGV_RECOVERY
2897: if (debug == d_faux)
2898: {
2899: sigsegv_deinstall_handler();
2900: }
2901: # endif
2902:
1.1 bertrand 2903: if ((*s_etat_processus).langue == 'F')
2904: {
2905: printf("+++Système : Initialisation des signaux POSIX "
2906: "impossible\n");
2907: }
2908: else
2909: {
2910: printf("+++System : Initialization of POSIX signals "
2911: "failed\n");
2912: }
2913:
2914: return(EXIT_FAILURE);
2915: }
1.94 bertrand 2916:
2917: signal_test = SIGTEST;
1.133 bertrand 2918: raise(SIGBUS);
1.94 bertrand 2919:
1.115 bertrand 2920: attente.tv_sec = 0;
2921: attente.tv_nsec = 1000000;
2922:
2923: for(i = 0; (i < 1000) && (signal_test == SIGTEST); i++)
2924: {
2925: nanosleep(&attente, NULL);
2926: }
2927:
1.94 bertrand 2928: if (signal_test != SIGBUS)
2929: {
1.124 bertrand 2930: # ifndef SEMAPHORES_NOMMES
2931: sem_post(&((*s_etat_processus).semaphore_fork));
2932: sem_destroy(&((*s_etat_processus)
2933: .semaphore_fork));
2934: # else
2935: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2936: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2937: getpid(), pthread_self(), SEM_FORK);
2938: # endif
2939:
2940: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2941: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2942:
2943: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2944: stackoverflow_deinstall_handler();
2945: # endif
2946:
2947: # ifdef HAVE_SIGSEGV_RECOVERY
2948: if (debug == d_faux)
2949: {
2950: sigsegv_deinstall_handler();
2951: }
2952: # endif
2953:
1.94 bertrand 2954: erreur = d_es_signal;
2955:
2956: if ((*s_etat_processus).langue == 'F')
2957: {
2958: printf("+++Système : Initialisation des signaux POSIX "
2959: "impossible\n");
2960: }
2961: else
2962: {
2963: printf("+++System : Initialization of POSIX signals "
2964: "failed\n");
2965: }
2966:
2967: return(EXIT_FAILURE);
2968: }
2969:
1.1 bertrand 2970: }
2971:
2972: if (option_n == d_vrai)
2973: {
1.83 bertrand 2974: action.sa_handler = interruption4;
1.94 bertrand 2975: action.sa_flags = 0;
1.1 bertrand 2976:
2977: if (sigaction(SIGHUP, &action, NULL) != 0)
2978: {
1.124 bertrand 2979: # ifndef SEMAPHORES_NOMMES
2980: sem_post(&((*s_etat_processus).semaphore_fork));
2981: sem_destroy(&((*s_etat_processus)
2982: .semaphore_fork));
2983: # else
2984: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 2985: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 2986: getpid(), pthread_self(), SEM_FORK);
2987: # endif
2988:
2989: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 2990: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 2991:
2992: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
2993: stackoverflow_deinstall_handler();
2994: # endif
2995:
2996: # ifdef HAVE_SIGSEGV_RECOVERY
2997: if (debug == d_faux)
2998: {
2999: sigsegv_deinstall_handler();
3000: }
3001: # endif
3002:
1.1 bertrand 3003: if ((*s_etat_processus).langue == 'F')
3004: {
3005: printf("+++Système : Initialisation des signaux POSIX "
3006: "impossible\n");
3007: }
3008: else
3009: {
3010: printf("+++System : Initialization of POSIX signals "
3011: "failed\n");
3012: }
3013:
3014: return(EXIT_FAILURE);
3015: }
3016: }
3017:
3018: if (mode_interactif == d_vrai)
3019: {
3020: printf("\n");
3021:
3022: if ((*s_etat_processus).langue == 'F')
3023: {
3024: printf("+++Ce logiciel est un logiciel libre"
3025: " sans aucune garantie de "
3026: "fonctionnement.\n");
3027: printf("+++Pour plus de détails, utilisez la "
3028: "commande 'warranty'.\n");
3029: }
3030: else
3031: {
3032: printf("+++This is a free software with "
3033: "absolutely no warranty.\n");
3034: printf("+++For details, type 'warranty'.\n");
3035: }
3036:
3037: printf("\n");
3038:
3039: traitement_fichier_temporaire = 'Y';
3040:
3041: if ((nom_fichier_temporaire =
3042: creation_nom_fichier(s_etat_processus, (*s_etat_processus)
3043: .chemin_fichiers_temporaires)) == NULL)
3044: {
1.124 bertrand 3045: # ifndef SEMAPHORES_NOMMES
3046: sem_post(&((*s_etat_processus).semaphore_fork));
3047: sem_destroy(&((*s_etat_processus)
3048: .semaphore_fork));
3049: # else
3050: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3051: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3052: getpid(), pthread_self(), SEM_FORK);
3053: # endif
3054:
3055: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3056: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3057:
3058: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3059: stackoverflow_deinstall_handler();
3060: # endif
3061:
3062: # ifdef HAVE_SIGSEGV_RECOVERY
3063: if (debug == d_faux)
3064: {
3065: sigsegv_deinstall_handler();
3066: }
3067: # endif
3068:
1.1 bertrand 3069: if ((*s_etat_processus).langue == 'F')
3070: {
3071: printf("+++Système : Fichier indisponible\n");
3072: }
3073: else
3074: {
3075: printf("+++System : File unavailable\n");
3076: }
3077:
3078: return(EXIT_FAILURE);
3079: }
3080:
3081: if ((f_source = fopen(nom_fichier_temporaire, "w"))
3082: == NULL)
3083: {
1.124 bertrand 3084: # ifndef SEMAPHORES_NOMMES
3085: sem_post(&((*s_etat_processus).semaphore_fork));
3086: sem_destroy(&((*s_etat_processus)
3087: .semaphore_fork));
3088: # else
3089: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3090: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3091: getpid(), pthread_self(), SEM_FORK);
3092: # endif
3093:
3094: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3095: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3096:
3097: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3098: stackoverflow_deinstall_handler();
3099: # endif
3100:
3101: # ifdef HAVE_SIGSEGV_RECOVERY
3102: if (debug == d_faux)
3103: {
3104: sigsegv_deinstall_handler();
3105: }
3106: # endif
3107:
1.1 bertrand 3108: if ((*s_etat_processus).langue == 'F')
3109: {
3110: printf("+++Système : Fichier introuvable\n");
3111: }
3112: else
3113: {
3114: printf("+++System : File not found\n");
3115: }
3116:
3117: return(EXIT_FAILURE);
3118: }
3119:
3120: if (fprintf(f_source, "MODE_INTERACTIF\n") < 0)
3121: {
1.124 bertrand 3122: # ifndef SEMAPHORES_NOMMES
3123: sem_post(&((*s_etat_processus).semaphore_fork));
3124: sem_destroy(&((*s_etat_processus)
3125: .semaphore_fork));
3126: # else
3127: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3128: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3129: getpid(), pthread_self(), SEM_FORK);
3130: # endif
3131:
3132: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3133: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3134:
3135: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3136: stackoverflow_deinstall_handler();
3137: # endif
3138:
3139: # ifdef HAVE_SIGSEGV_RECOVERY
3140: if (debug == d_faux)
3141: {
3142: sigsegv_deinstall_handler();
3143: }
3144: # endif
3145:
1.1 bertrand 3146: if ((*s_etat_processus).langue == 'F')
3147: {
3148: printf("+++Système : Erreur d'écriture dans un fichier\n");
3149: }
3150: else
3151: {
3152: printf("+++System : Cannot write in file\n");
3153: }
3154:
3155: return(EXIT_FAILURE);
3156: }
3157:
3158: if (fprintf(f_source,
3159: "<< DO HALT UNTIL FALSE END >>\n") < 0)
3160: {
1.124 bertrand 3161: # ifndef SEMAPHORES_NOMMES
3162: sem_post(&((*s_etat_processus).semaphore_fork));
3163: sem_destroy(&((*s_etat_processus)
3164: .semaphore_fork));
3165: # else
3166: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3167: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3168: getpid(), pthread_self(), SEM_FORK);
3169: # endif
3170:
3171: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3172: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3173:
3174: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3175: stackoverflow_deinstall_handler();
3176: # endif
3177:
3178: # ifdef HAVE_SIGSEGV_RECOVERY
3179: if (debug == d_faux)
3180: {
3181: sigsegv_deinstall_handler();
3182: }
3183: # endif
3184:
1.1 bertrand 3185: if ((*s_etat_processus).langue == 'F')
3186: {
3187: printf("+++Système : Erreur d'écriture dans un fichier\n");
3188: }
3189: else
3190: {
3191: printf("+++System : Cannot write in file\n");
3192: }
3193:
3194: return(EXIT_FAILURE);
3195: }
3196:
3197: if (fclose(f_source) != 0)
3198: {
1.124 bertrand 3199: # ifndef SEMAPHORES_NOMMES
3200: sem_post(&((*s_etat_processus).semaphore_fork));
3201: sem_destroy(&((*s_etat_processus)
3202: .semaphore_fork));
3203: # else
3204: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3205: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3206: getpid(), pthread_self(), SEM_FORK);
3207: # endif
3208:
3209: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3210: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3211:
3212: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3213: stackoverflow_deinstall_handler();
3214: # endif
3215:
3216: # ifdef HAVE_SIGSEGV_RECOVERY
3217: if (debug == d_faux)
3218: {
3219: sigsegv_deinstall_handler();
3220: }
3221: # endif
3222:
1.1 bertrand 3223: if ((*s_etat_processus).langue == 'F')
3224: {
3225: printf("+++Système : Fichier indisponible\n");
3226: }
3227: else
3228: {
3229: printf("+++System : File unavailable\n");
3230: }
3231:
3232: return(EXIT_FAILURE);
3233: }
3234:
3235: (*s_etat_processus).lancement_interactif = d_vrai;
3236: (*s_etat_processus).nom_fichier_source =
3237: nom_fichier_temporaire;
3238:
3239: presence_definition = 'O';
3240: }
3241: else
3242: {
3243: nom_fichier_temporaire = NULL;
3244: }
3245:
3246: if ((*s_etat_processus).nom_fichier_source == NULL)
3247: {
3248: erreur_fichier = d_erreur;
3249: }
3250: else
3251: {
3252: erreur_fichier = caracteristiques_fichier(s_etat_processus,
3253: (*s_etat_processus).nom_fichier_source,
3254: &existence, &ouverture, &unite_fichier);
3255: }
3256:
3257: if (((existence == d_faux) || (erreur_fichier != d_absence_erreur)) &&
3258: (option_S == d_faux))
3259: {
1.124 bertrand 3260: # ifndef SEMAPHORES_NOMMES
3261: sem_post(&((*s_etat_processus).semaphore_fork));
3262: sem_destroy(&((*s_etat_processus).semaphore_fork));
3263: # else
3264: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3265: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3266: getpid(), pthread_self(), SEM_FORK);
3267: # endif
3268:
3269: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3270: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3271:
3272: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3273: stackoverflow_deinstall_handler();
3274: # endif
3275:
3276: # ifdef HAVE_SIGSEGV_RECOVERY
3277: if (debug == d_faux)
3278: {
3279: sigsegv_deinstall_handler();
3280: }
3281: # endif
3282:
1.1 bertrand 3283: if (presence_definition == 'O')
3284: {
3285: if ((*s_etat_processus).langue == 'F')
3286: {
3287: printf("+++Erreur : Fichier %s inexistant\n",
3288: (*s_etat_processus).nom_fichier_source);
3289: }
3290: else
3291: {
3292: printf("+++Error : File %s not found\n",
3293: (*s_etat_processus).nom_fichier_source);
3294: }
3295:
1.13 bertrand 3296: erreur = d_erreur;
1.1 bertrand 3297: }
3298: else
3299: {
3300: if ((*s_etat_processus).langue == 'F')
3301: {
3302: printf("+++Erreur : Absence de définition à exécuter\n");
3303: }
3304: else
3305: {
3306: printf("+++Error : Any executable definition\n");
3307: }
3308: }
1.3 bertrand 3309:
3310: return(EXIT_FAILURE);
1.1 bertrand 3311: }
3312:
3313: if ((*s_etat_processus).chemin_fichiers_temporaires == NULL)
3314: {
1.124 bertrand 3315: # ifndef SEMAPHORES_NOMMES
3316: sem_post(&((*s_etat_processus).semaphore_fork));
3317: sem_destroy(&((*s_etat_processus).semaphore_fork));
3318: # else
3319: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3320: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3321: getpid(), pthread_self(), SEM_FORK);
3322: # endif
3323:
3324: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3325: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3326:
3327: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3328: stackoverflow_deinstall_handler();
3329: # endif
3330:
3331: # ifdef HAVE_SIGSEGV_RECOVERY
3332: if (debug == d_faux)
3333: {
3334: sigsegv_deinstall_handler();
3335: }
3336: # endif
3337:
1.1 bertrand 3338: if ((*s_etat_processus).langue == 'F')
3339: {
3340: printf("+++Système : Chemin des fichiers temporaires nul\n");
3341: }
3342: else
3343: {
3344: printf("+++System : Null temporary files path\n");
3345: }
3346:
3347: return(EXIT_FAILURE);
3348: }
3349:
3350: if ((*s_etat_processus).debug == d_vrai)
3351: {
3352: if ((*s_etat_processus).langue == 'F')
3353: {
3354: printf("[%d] Chemin des fichiers temporaires %s\n\n",
3355: (int) getpid(),
3356: (*s_etat_processus).chemin_fichiers_temporaires);
3357: }
3358: else
3359: {
3360: printf("[%d] Temporary files path %s\n\n",
3361: (int) getpid(),
3362: (*s_etat_processus).chemin_fichiers_temporaires);
3363: }
3364: }
3365:
1.13 bertrand 3366: if ((erreur == d_absence_erreur) && (presence_definition == 'O'))
1.1 bertrand 3367: {
3368: (*s_etat_processus).profilage = (option_P != 0) ? d_vrai : d_faux;
3369: (*s_etat_processus).niveau_profilage = option_P;
3370: (*s_etat_processus).pile_profilage = NULL;
3371: (*s_etat_processus).pile_profilage_fonctions = NULL;
3372: gettimeofday(&((*s_etat_processus).horodatage_profilage), NULL);
3373:
3374: (*s_etat_processus).liste_mutexes = NULL;
1.117 bertrand 3375: (*s_etat_processus).sections_critiques = 0;
1.143 bertrand 3376: (*s_etat_processus).initialisation_scheduler = d_faux;
1.1 bertrand 3377:
3378: (*s_etat_processus).test_instruction = 'N';
3379: (*s_etat_processus).nombre_arguments = 0;
3380: (*s_etat_processus).affichage_arguments = 'N';
1.6 bertrand 3381: (*s_etat_processus).autorisation_conversion_chaine = 'Y';
1.1 bertrand 3382: (*s_etat_processus).autorisation_evaluation_nom = 'Y';
1.62 bertrand 3383:
3384: if (mode_interactif == d_vrai)
3385: {
3386: (*s_etat_processus).autorisation_nom_implicite = 'Y';
3387: }
3388: else
3389: {
3390: (*s_etat_processus).autorisation_nom_implicite = 'N';
3391: }
3392:
1.1 bertrand 3393: (*s_etat_processus).autorisation_empilement_programme = 'N';
3394: (*s_etat_processus).requete_arret = 'N';
1.4 bertrand 3395: (*s_etat_processus).evaluation_forcee = 'N';
1.51 bertrand 3396: (*s_etat_processus).recherche_type = 'N';
1.1 bertrand 3397:
3398: (*s_etat_processus).constante_symbolique = 'N';
3399: (*s_etat_processus).traitement_symbolique = 'N';
3400:
3401: (*s_etat_processus).expression_courante = NULL;
3402: (*s_etat_processus).objet_courant = NULL;
3403: (*s_etat_processus).evaluation_expression_compilee = 'N';
3404:
3405: (*s_etat_processus).l_base_pile = NULL;
3406: (*s_etat_processus).l_base_pile_last = NULL;
3407:
1.64 bertrand 3408: (*s_etat_processus).s_arbre_variables = NULL;
1.65 bertrand 3409: (*s_etat_processus).l_liste_variables_par_niveau = NULL;
1.127 bertrand 3410: (*s_etat_processus).l_liste_variables_statiques = NULL;
1.1 bertrand 3411: (*s_etat_processus).gel_liste_variables = d_faux;
1.127 bertrand 3412: s_arbre_variables_partagees = NULL;
3413: l_liste_variables_partagees = NULL;
3414: (*s_etat_processus).s_arbre_variables_partagees =
3415: &s_arbre_variables_partagees;
3416: (*s_etat_processus).l_liste_variables_partagees =
3417: &l_liste_variables_partagees;
1.64 bertrand 3418: (*s_etat_processus).pointeur_variable_courante = NULL;
1.119 bertrand 3419: (*s_etat_processus).pointeur_variable_statique_courante = NULL;
1.127 bertrand 3420: (*s_etat_processus).pointeur_variable_partagee_courante = NULL;
1.1 bertrand 3421: (*s_etat_processus).niveau_courant = 0;
3422: (*s_etat_processus).niveau_initial = 0;
3423: (*s_etat_processus).creation_variables_statiques = d_faux;
3424: (*s_etat_processus).creation_variables_partagees = d_faux;
3425:
3426: (*s_etat_processus).s_bibliotheques = NULL;
3427: (*s_etat_processus).s_instructions_externes = NULL;
3428: (*s_etat_processus).nombre_instructions_externes = 0;
3429:
3430: (*s_etat_processus).systeme_axes = 0;
3431:
3432: (*s_etat_processus).x_min = -10.;
3433: (*s_etat_processus).x_max = 10.;
3434: (*s_etat_processus).y_min = -10.;
3435: (*s_etat_processus).y_max = 10.;
3436: (*s_etat_processus).z_min = -10.;
3437: (*s_etat_processus).z_max = 10.;
3438:
3439: (*s_etat_processus).x2_min = -10.;
3440: (*s_etat_processus).x2_max = 10.;
3441: (*s_etat_processus).y2_min = -10.;
3442: (*s_etat_processus).y2_max = 10.;
3443: (*s_etat_processus).z2_min = -10.;
3444: (*s_etat_processus).z2_max = 10.;
3445:
3446: (*s_etat_processus).resolution = .01;
3447:
3448: (*s_etat_processus).souris_active = d_faux;
3449:
3450: (*s_etat_processus).echelle_automatique_x = d_faux;
3451: (*s_etat_processus).echelle_automatique_y = d_faux;
3452: (*s_etat_processus).echelle_automatique_z = d_faux;
3453:
3454: (*s_etat_processus).echelle_automatique_x2 = d_faux;
3455: (*s_etat_processus).echelle_automatique_y2 = d_faux;
3456: (*s_etat_processus).echelle_automatique_z2 = d_faux;
3457:
3458: (*s_etat_processus).echelle_log_x = d_faux;
3459: (*s_etat_processus).echelle_log_y = d_faux;
3460: (*s_etat_processus).echelle_log_z = d_faux;
3461:
3462: (*s_etat_processus).echelle_log_x2 = d_faux;
3463: (*s_etat_processus).echelle_log_y2 = d_faux;
3464: (*s_etat_processus).echelle_log_z2 = d_faux;
3465:
3466: (*s_etat_processus).point_de_vue_theta = 4 * atan((real8) 1) / 6;
3467: (*s_etat_processus).point_de_vue_phi = 4 * atan((real8) 1) / 3;
3468: (*s_etat_processus).echelle_3D = 1;
3469:
3470: strcpy((*s_etat_processus).type_trace_eq, "FONCTION");
3471: strcpy((*s_etat_processus).type_trace_sigma, "POINTS");
3472: (*s_etat_processus).fichiers_graphiques = NULL;
3473: (*s_etat_processus).nom_fichier_impression = NULL;
3474: strcpy((*s_etat_processus).format_papier, "a4paper");
3475: (*s_etat_processus).entree_standard = NULL;
3476: (*s_etat_processus).s_marques = NULL;
3477: (*s_etat_processus).requete_nouveau_plan = d_vrai;
3478: (*s_etat_processus).mise_a_jour_trace_requise = d_faux;
3479:
3480: (*s_etat_processus).l_base_pile = NULL;
3481: (*s_etat_processus).hauteur_pile_operationnelle = 0;
3482: (*s_etat_processus).l_base_pile_contextes = NULL;
3483: (*s_etat_processus).l_base_pile_taille_contextes = NULL;
3484:
3485: (*s_etat_processus).position_courante = 0;
3486:
3487: (*s_etat_processus).l_base_pile_systeme = NULL;
3488: (*s_etat_processus).hauteur_pile_systeme = 0;
3489:
3490: (*s_etat_processus).l_base_pile_processus = NULL;
3491: (*s_etat_processus).presence_pipes = d_faux;
3492: (*s_etat_processus).pipe_donnees = 0;
3493: (*s_etat_processus).pipe_acquittement = 0;
3494: (*s_etat_processus).pipe_injections = 0;
3495: (*s_etat_processus).pipe_nombre_injections = 0;
3496: (*s_etat_processus).nombre_objets_injectes = 0;
3497: (*s_etat_processus).nombre_objets_envoyes_non_lus = 0;
3498: (*s_etat_processus).pourcentage_maximal_cpu = 100;
3499: (*s_etat_processus).temps_maximal_cpu = 0;
3500: (*s_etat_processus).thread_fusible = 0;
3501: (*s_etat_processus).presence_fusible = d_faux;
3502:
3503: (*s_etat_processus).niveau_recursivite = 0;
3504: (*s_etat_processus).generateur_aleatoire = NULL;
3505: (*s_etat_processus).type_generateur_aleatoire = NULL;
3506:
3507: (*s_etat_processus).colonne_statistique_1 = 1;
3508: (*s_etat_processus).colonne_statistique_2 = 2;
3509:
3510: (*s_etat_processus).debug_programme = d_faux;
3511: (*s_etat_processus).execution_pas_suivant = d_faux;
3512: (*s_etat_processus).traitement_instruction_halt = d_faux;
3513:
3514: (*s_etat_processus).derniere_exception = d_ep;
3515: (*s_etat_processus).derniere_erreur_systeme = d_es;
3516: (*s_etat_processus).derniere_erreur_execution = d_ex;
3517: (*s_etat_processus).derniere_erreur_evaluation = d_ex;
3518: (*s_etat_processus).derniere_erreur_fonction_externe = 0;
3519:
3520: (*s_etat_processus).erreur_processus_fils = d_faux;
3521: (*s_etat_processus).erreur_systeme_processus_fils = d_es;
3522: (*s_etat_processus).erreur_execution_processus_fils = d_ex;
3523: (*s_etat_processus).pid_erreur_processus_fils = 0;
3524: (*s_etat_processus).exception_processus_fils = d_ep;
3525: (*s_etat_processus).core = core;
3526: (*s_etat_processus).invalidation_message_erreur = d_faux;
3527: (*s_etat_processus).s_objet_errone = NULL;
3528: (*s_etat_processus).s_objet_erreur = NULL;
3529:
3530: (*s_etat_processus).retour_routine_evaluation = 'N';
3531:
3532: (*s_etat_processus).traitement_interruption = 'N';
3533: (*s_etat_processus).traitement_interruptible = 'Y';
3534: (*s_etat_processus).nombre_interruptions_en_queue = 0;
3535: (*s_etat_processus).nombre_interruptions_non_affectees = 0;
3536:
3537: for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
3538: {
3539: (*s_etat_processus).masque_interruptions[i] = 'N';
3540: (*s_etat_processus).queue_interruptions[i] = 0;
3541: (*s_etat_processus).corps_interruptions[i] = NULL;
3542: (*s_etat_processus).pile_origine_interruptions[i] = NULL;
3543: }
3544:
1.20 bertrand 3545: (*s_etat_processus).at_exit = NULL;
1.34 bertrand 3546: (*s_etat_processus).at_poke = NULL;
3547: (*s_etat_processus).traitement_at_poke = 'N';
1.19 bertrand 3548:
1.1 bertrand 3549: (*s_etat_processus).pointeurs_caracteres = NULL;
3550: (*s_etat_processus).arbre_instructions = NULL;
3551:
3552: (*s_etat_processus).tid_processus_pere = pthread_self();
1.113 bertrand 3553: (*s_etat_processus).tid = pthread_self();
1.1 bertrand 3554: (*s_etat_processus).pid_processus_pere = getpid();
3555: (*s_etat_processus).processus_detache = d_vrai;
3556: (*s_etat_processus).var_volatile_processus_pere = -1;
1.45 bertrand 3557: (*s_etat_processus).var_volatile_processus_racine = -1;
1.1 bertrand 3558: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
3559: (*s_etat_processus).var_volatile_alarme = 0;
3560: (*s_etat_processus).var_volatile_requete_arret = 0;
3561: (*s_etat_processus).var_volatile_requete_arret2 = 0;
3562: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
3563: (*s_etat_processus).var_volatile_traitement_sigint = 0;
3564: (*s_etat_processus).var_volatile_recursivite = 0;
3565: (*s_etat_processus).var_volatile_exception_gsl = 0;
1.22 bertrand 3566: (*s_etat_processus).arret_depuis_abort = 0;
1.83 bertrand 3567: (*s_etat_processus).pointeur_signal_lecture = 0;
3568: (*s_etat_processus).pointeur_signal_ecriture = 0;
1.1 bertrand 3569:
3570: initialisation_allocateur(s_etat_processus);
3571: initialisation_drapeaux(s_etat_processus);
1.65 bertrand 3572: initialisation_variables(s_etat_processus);
3573: initialisation_instructions(s_etat_processus);
1.1 bertrand 3574:
3575: if ((*s_etat_processus).erreur_systeme != d_es)
3576: {
1.124 bertrand 3577: # ifndef SEMAPHORES_NOMMES
3578: sem_post(&((*s_etat_processus).semaphore_fork));
3579: sem_destroy(&((*s_etat_processus).semaphore_fork));
3580: # else
3581: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3582: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3583: getpid(), pthread_self(), SEM_FORK);
3584: # endif
3585:
3586: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3587: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3588:
3589: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3590: stackoverflow_deinstall_handler();
3591: # endif
3592:
3593: # ifdef HAVE_SIGSEGV_RECOVERY
3594: if (debug == d_faux)
3595: {
3596: sigsegv_deinstall_handler();
3597: }
3598: # endif
3599:
1.1 bertrand 3600: if ((*s_etat_processus).langue == 'F')
3601: {
3602: printf("+++Système : Mémoire insuffisante\n");
3603: }
3604: else
3605: {
3606: printf("+++System : Not enough memory\n");
3607: }
3608:
3609: return(EXIT_FAILURE);
3610: }
3611:
3612: if (((*s_etat_processus).instruction_derniere_erreur =
1.32 bertrand 3613: malloc(sizeof(unsigned char))) == NULL)
1.1 bertrand 3614: {
1.124 bertrand 3615: # ifndef SEMAPHORES_NOMMES
3616: sem_post(&((*s_etat_processus).semaphore_fork));
3617: sem_destroy(&((*s_etat_processus).semaphore_fork));
3618: # else
3619: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3620: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3621: getpid(), pthread_self(), SEM_FORK);
3622: # endif
3623:
3624: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3625: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3626:
3627: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3628: stackoverflow_deinstall_handler();
3629: # endif
3630:
3631: # ifdef HAVE_SIGSEGV_RECOVERY
3632: if (debug == d_faux)
3633: {
3634: sigsegv_deinstall_handler();
3635: }
3636: # endif
3637:
1.1 bertrand 3638: erreur = d_es_allocation_memoire;
3639:
3640: if ((*s_etat_processus).langue == 'F')
3641: {
3642: printf("+++Système : Mémoire insuffisante\n");
3643: }
3644: else
3645: {
3646: printf("+++System : Not enough memory\n");
3647: }
3648:
3649: return(EXIT_FAILURE);
3650: }
3651:
3652: strcpy((*s_etat_processus).instruction_derniere_erreur, "");
3653: (*s_etat_processus).niveau_derniere_erreur = 0;
3654:
3655: if (traitement_fichier_temporaire == 'Y')
3656: {
3657: (*s_etat_processus).mode_interactif = 'Y';
3658: }
3659: else
3660: {
3661: (*s_etat_processus).mode_interactif = 'N';
3662: }
3663:
3664: if (((*s_etat_processus).instruction_courante = (unsigned char *)
3665: malloc(sizeof(unsigned char))) == NULL)
3666: {
1.124 bertrand 3667: # ifndef SEMAPHORES_NOMMES
3668: sem_post(&((*s_etat_processus).semaphore_fork));
3669: sem_destroy(&((*s_etat_processus).semaphore_fork));
3670: # else
3671: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3672: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3673: getpid(), pthread_self(), SEM_FORK);
3674: # endif
3675:
3676: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3677: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3678:
3679: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3680: stackoverflow_deinstall_handler();
3681: # endif
3682:
3683: # ifdef HAVE_SIGSEGV_RECOVERY
3684: if (debug == d_faux)
3685: {
3686: sigsegv_deinstall_handler();
3687: }
3688: # endif
3689:
1.1 bertrand 3690: erreur = d_es_allocation_memoire;
3691:
3692: if ((*s_etat_processus).langue == 'F')
3693: {
3694: printf("+++Système : Mémoire insuffisante\n");
3695: }
3696: else
3697: {
3698: printf("+++System : Not enough memory\n");
3699: }
3700:
3701: return(EXIT_FAILURE);
3702: }
3703:
3704: (*s_etat_processus).instruction_courante[0] = d_code_fin_chaine;
3705:
3706: empilement_pile_systeme(s_etat_processus);
3707:
3708: free((*s_etat_processus).instruction_courante);
3709:
1.41 bertrand 3710: if ((*s_etat_processus).erreur_systeme != d_es)
1.1 bertrand 3711: {
3712: erreur = d_es_allocation_memoire;
3713: }
3714: else
3715: {
3716: (*((*s_etat_processus).l_base_pile_systeme))
3717: .retour_definition = 'Y';
3718:
1.111 bertrand 3719: (*s_etat_processus).indep = allocation(s_etat_processus, NON);
3720: (*s_etat_processus).depend = allocation(s_etat_processus, NON);
1.1 bertrand 3721: (*s_etat_processus).parametres_courbes_de_niveau =
1.111 bertrand 3722: allocation(s_etat_processus, NON);
1.1 bertrand 3723:
3724: if (((*s_etat_processus).indep != NULL) &&
3725: ((*s_etat_processus).depend != NULL) &&
3726: ((*s_etat_processus).parametres_courbes_de_niveau
3727: != NULL))
3728: {
3729: (*((*s_etat_processus).indep)).type = NOM;
3730: (*((*s_etat_processus).depend)).type = NOM;
3731: (*((*s_etat_processus).
3732: parametres_courbes_de_niveau)).type = LST;
3733:
3734: initialisation_objet((*s_etat_processus).indep);
3735: initialisation_objet((*s_etat_processus).depend);
3736: initialisation_objet((*s_etat_processus)
3737: .parametres_courbes_de_niveau);
3738:
3739: (*((*s_etat_processus).indep)).objet = (struct_nom *)
3740: malloc(sizeof(struct_nom));
3741: (*((*s_etat_processus).depend)).objet = (struct_nom *)
3742: malloc(sizeof(struct_nom));
3743: (*((*s_etat_processus).parametres_courbes_de_niveau))
3744: .objet = (struct_liste_chainee *)
3745: malloc(sizeof(struct_liste_chainee));
3746:
3747: if (((*((*s_etat_processus).depend)).objet == NULL) ||
3748: ((*((*s_etat_processus).depend)).objet == NULL) ||
3749: ((*((*s_etat_processus).
3750: parametres_courbes_de_niveau)).objet == NULL))
3751: {
1.124 bertrand 3752: # ifndef SEMAPHORES_NOMMES
3753: sem_post(&((*s_etat_processus).semaphore_fork));
3754: sem_destroy(&((*s_etat_processus).semaphore_fork));
3755: # else
3756: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3757: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3758: getpid(), pthread_self(), SEM_FORK);
3759: # endif
3760:
3761: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3762: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3763:
3764: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3765: stackoverflow_deinstall_handler();
3766: # endif
3767:
3768: # ifdef HAVE_SIGSEGV_RECOVERY
3769: if (debug == d_faux)
3770: {
3771: sigsegv_deinstall_handler();
3772: }
3773: # endif
3774:
1.1 bertrand 3775: erreur = d_es_allocation_memoire;
3776:
3777: if ((*s_etat_processus).langue == 'F')
3778: {
3779: printf("+++Système : Mémoire insuffisante\n");
3780: }
3781: else
3782: {
3783: printf("+++System : Not enough memory\n");
3784: }
3785:
3786: return(EXIT_FAILURE);
3787: }
3788:
3789: (*((struct_nom *) (*((*s_etat_processus).indep)).objet))
3790: .nom = malloc(2 * sizeof(unsigned char));
3791: (*((struct_nom *) (*((*s_etat_processus).depend)).objet))
3792: .nom = malloc(2 * sizeof(unsigned char));
3793:
3794: if (((*((struct_nom *) (*((*s_etat_processus).indep))
3795: .objet)).nom == NULL) || ((*((struct_nom *)
3796: (*((*s_etat_processus).depend)).objet)).nom ==
3797: NULL))
3798: {
1.124 bertrand 3799: # ifndef SEMAPHORES_NOMMES
3800: sem_post(&((*s_etat_processus).semaphore_fork));
3801: sem_destroy(&((*s_etat_processus).semaphore_fork));
3802: # else
3803: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3804: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3805: getpid(), pthread_self(), SEM_FORK);
3806: # endif
3807:
3808: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3809: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3810:
3811: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3812: stackoverflow_deinstall_handler();
3813: # endif
3814:
3815: # ifdef HAVE_SIGSEGV_RECOVERY
3816: if (debug == d_faux)
3817: {
3818: sigsegv_deinstall_handler();
3819: }
3820: # endif
3821:
1.1 bertrand 3822: erreur = d_es_allocation_memoire;
3823:
3824: if ((*s_etat_processus).langue == 'F')
3825: {
3826: printf("+++Système : Mémoire insuffisante\n");
3827: }
3828: else
3829: {
3830: printf("+++System : Not enough memory\n");
3831: }
3832:
3833: return(EXIT_FAILURE);
3834: }
3835:
3836: strcpy((*((struct_nom *) (*((*s_etat_processus).indep))
3837: .objet)).nom, "X");
3838: strcpy((*((struct_nom *) (*((*s_etat_processus).depend))
3839: .objet)).nom, "Y");
3840:
3841: (*((struct_nom *) (*((*s_etat_processus).indep))
3842: .objet)).symbole = d_vrai;
3843: (*((struct_nom *) (*((*s_etat_processus).depend))
3844: .objet)).symbole = d_vrai;
3845:
3846: (*((struct_liste_chainee *) (*((*s_etat_processus)
3847: .parametres_courbes_de_niveau)).objet)).suivant
3848: = NULL;
3849:
3850: (*((struct_liste_chainee *) (*((*s_etat_processus)
3851: .parametres_courbes_de_niveau)).objet)).donnee
3852: = malloc(sizeof(struct_objet));
3853:
3854: (*s_etat_processus).legende =
3855: malloc(sizeof(unsigned char));
3856: (*s_etat_processus).label_x =
3857: malloc(sizeof(unsigned char));
3858: (*s_etat_processus).label_y =
3859: malloc(sizeof(unsigned char));
3860: (*s_etat_processus).label_z =
3861: malloc(sizeof(unsigned char));
3862: (*s_etat_processus).titre =
3863: malloc(sizeof(unsigned char));
3864:
3865: if (((*s_etat_processus).label_x == NULL) ||
3866: ((*s_etat_processus).label_y == NULL) ||
3867: ((*s_etat_processus).label_z == NULL) ||
3868: ((*s_etat_processus).titre == NULL) ||
3869: ((*s_etat_processus).legende == NULL) ||
3870: ((*((struct_liste_chainee *) (*((*s_etat_processus)
3871: .parametres_courbes_de_niveau)).objet)).donnee
3872: == NULL))
3873: {
1.124 bertrand 3874: # ifndef SEMAPHORES_NOMMES
3875: sem_post(&((*s_etat_processus).semaphore_fork));
3876: sem_destroy(&((*s_etat_processus).semaphore_fork));
3877: # else
3878: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3879: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3880: getpid(), pthread_self(), SEM_FORK);
3881: # endif
3882:
3883: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3884: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3885:
3886: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3887: stackoverflow_deinstall_handler();
3888: # endif
3889:
3890: # ifdef HAVE_SIGSEGV_RECOVERY
3891: if (debug == d_faux)
3892: {
3893: sigsegv_deinstall_handler();
3894: }
3895: # endif
3896:
1.1 bertrand 3897: erreur = d_es_allocation_memoire;
3898:
3899: if ((*s_etat_processus).langue == 'F')
3900: {
3901: printf("+++Système : Mémoire insuffisante\n");
3902: }
3903: else
3904: {
3905: printf("+++System : Not enough memory\n");
3906: }
3907:
3908: return(EXIT_FAILURE);
3909: }
3910:
3911: (*(*((struct_liste_chainee *) (*((*s_etat_processus)
3912: .parametres_courbes_de_niveau)).objet)).donnee)
3913: .type = CHN;
3914:
3915: initialisation_objet((*((struct_liste_chainee *)
3916: (*((*s_etat_processus)
3917: .parametres_courbes_de_niveau))
3918: .objet)).donnee);
3919:
3920: if (((*(*((struct_liste_chainee *) (*((*s_etat_processus)
3921: .parametres_courbes_de_niveau)).objet)).donnee)
3922: .objet = malloc(10 * sizeof(unsigned char)))
3923: == NULL)
3924: {
1.124 bertrand 3925: # ifndef SEMAPHORES_NOMMES
3926: sem_post(&((*s_etat_processus).semaphore_fork));
3927: sem_destroy(&((*s_etat_processus).semaphore_fork));
3928: # else
3929: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 3930: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 3931: getpid(), pthread_self(), SEM_FORK);
3932: # endif
3933:
3934: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 3935: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 3936:
3937: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
3938: stackoverflow_deinstall_handler();
3939: # endif
3940:
3941: # ifdef HAVE_SIGSEGV_RECOVERY
3942: if (debug == d_faux)
3943: {
3944: sigsegv_deinstall_handler();
3945: }
3946: # endif
3947:
1.1 bertrand 3948: erreur = d_es_allocation_memoire;
3949:
3950: if ((*s_etat_processus).langue == 'F')
3951: {
3952: printf("+++Système : Mémoire insuffisante\n");
3953: }
3954: else
3955: {
3956: printf("+++System : Not enough memory\n");
3957: }
3958:
3959: return(EXIT_FAILURE);
3960: }
3961:
3962: strcpy((unsigned char *) (*(*((struct_liste_chainee *)
3963: (*((*s_etat_processus)
3964: .parametres_courbes_de_niveau))
3965: .objet)).donnee).objet, "AUTOMATIC");
3966:
3967: (*s_etat_processus).label_x[0] = d_code_fin_chaine;
3968: (*s_etat_processus).label_y[0] = d_code_fin_chaine;
3969: (*s_etat_processus).label_z[0] = d_code_fin_chaine;
3970: (*s_etat_processus).titre[0] = d_code_fin_chaine;
3971: (*s_etat_processus).legende[0] = d_code_fin_chaine;
3972:
3973: (*s_etat_processus).nom_fichier_gnuplot = NULL;
3974: (*s_etat_processus).type_fichier_gnuplot = NULL;
3975:
3976: (*s_etat_processus).x_tics = 0;
3977: (*s_etat_processus).y_tics = 0;
3978: (*s_etat_processus).z_tics = 0;
3979:
3980: (*s_etat_processus).x_lines = d_vrai;
3981: (*s_etat_processus).y_lines = d_vrai;
3982: (*s_etat_processus).z_lines = d_vrai;
3983:
3984: (*s_etat_processus).mx_tics = -1;
3985: (*s_etat_processus).my_tics = -1;
3986: (*s_etat_processus).mz_tics = -1;
3987:
3988: (*s_etat_processus).mx_lines = d_faux;
3989: (*s_etat_processus).my_lines = d_faux;
3990: (*s_etat_processus).mz_lines = d_faux;
3991:
3992: (*s_etat_processus).x2_tics = -1;
3993: (*s_etat_processus).y2_tics = -1;
3994: (*s_etat_processus).z2_tics = -1;
3995:
3996: (*s_etat_processus).x2_lines = d_faux;
3997: (*s_etat_processus).y2_lines = d_faux;
3998: (*s_etat_processus).z2_lines = d_faux;
3999:
4000: (*s_etat_processus).mx2_tics = -1;
4001: (*s_etat_processus).my2_tics = -1;
4002: (*s_etat_processus).mz2_tics = -1;
4003:
4004: (*s_etat_processus).mx2_lines = d_faux;
4005: (*s_etat_processus).my2_lines = d_faux;
4006: (*s_etat_processus).mz2_lines = d_faux;
4007:
4008: (*s_etat_processus).mode_evaluation_expression = 'N';
4009: (*s_etat_processus).mode_execution_programme = 'Y';
4010:
4011: if ((*s_etat_processus).definitions_chainees == NULL)
4012: {
4013: if ((erreur = chainage(s_etat_processus)) !=
4014: d_absence_erreur)
4015: {
1.124 bertrand 4016: # ifndef SEMAPHORES_NOMMES
4017: sem_post(&((*s_etat_processus).semaphore_fork));
4018: sem_destroy(&((*s_etat_processus)
4019: .semaphore_fork));
4020: # else
4021: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 4022: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 4023: getpid(), pthread_self(), SEM_FORK);
4024: # endif
4025:
4026: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4027: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4028:
4029: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4030: stackoverflow_deinstall_handler();
4031: # endif
4032:
4033: # ifdef HAVE_SIGSEGV_RECOVERY
4034: if (debug == d_faux)
4035: {
4036: sigsegv_deinstall_handler();
4037: }
4038: # endif
4039:
1.1 bertrand 4040: if ((*s_etat_processus).langue == 'F')
4041: {
4042: printf("+++Fatal :"
4043: " Chaînage des définitions"
4044: " impossible\n");
4045: }
4046: else
4047: {
4048: printf("+++Fatal : Error in "
4049: "compilation\n");
4050: }
4051:
4052: if (traitement_fichier_temporaire == 'Y')
4053: {
4054: if (destruction_fichier(
4055: nom_fichier_temporaire)
4056: == d_erreur)
4057: {
4058: return(EXIT_FAILURE);
4059: }
4060:
4061: free(nom_fichier_temporaire);
4062: }
4063:
4064: return(EXIT_FAILURE);
4065: }
4066: }
4067:
1.195 bertrand 4068: /*
4069: * Chargement des bibliothèques pour gérer des
4070: * types externes lors des l'analyse syntaxique et
4071: * compilation.
4072: */
4073:
4074: l_bibliotheque_courante = l_bibliotheques;
4075:
4076: while(l_bibliotheque_courante != NULL)
4077: {
4078: if (empilement(s_etat_processus, &((*s_etat_processus)
4079: .l_base_pile), (*l_bibliotheque_courante)
4080: .donnee) == d_erreur)
4081: {
4082: # ifndef SEMAPHORES_NOMMES
4083: sem_post(&((*s_etat_processus).semaphore_fork));
4084: sem_destroy(&((*s_etat_processus)
4085: .semaphore_fork));
4086: # else
4087: sem_post((*s_etat_processus).semaphore_fork);
4088: sem_destroy3((*s_etat_processus).semaphore_fork,
4089: getpid(), pthread_self(), SEM_FORK);
4090: # endif
4091:
4092: liberation_contexte_cas(s_etat_processus);
4093: destruction_queue_signaux(s_etat_processus);
4094:
4095: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4096: stackoverflow_deinstall_handler();
4097: # endif
4098:
4099: # ifdef HAVE_SIGSEGV_RECOVERY
4100: if (debug == d_faux)
4101: {
4102: sigsegv_deinstall_handler();
4103: }
4104: # endif
4105:
4106: if ((*s_etat_processus).langue == 'F')
4107: {
4108: printf("+++Fatal :"
4109: " Chargement de la bibliothèse %s"
4110: " impossible\n", (unsigned char *)
4111: (*(*l_bibliotheque_courante).donnee)
4112: .objet);
4113: }
4114: else
4115: {
4116: printf("+++Fatal : Cannot load library %s\n",
4117: (*(*l_bibliotheque_courante).donnee)
4118: .objet);
4119: }
4120:
4121: if (traitement_fichier_temporaire == 'Y')
4122: {
4123: if (destruction_fichier(
4124: nom_fichier_temporaire)
4125: == d_erreur)
4126: {
4127: return(EXIT_FAILURE);
4128: }
4129:
4130: free(nom_fichier_temporaire);
4131: }
4132:
4133: return(EXIT_FAILURE);
4134: }
4135:
4136: instruction_use(s_etat_processus);
4137:
4138: if (depilement(s_etat_processus, &((*s_etat_processus)
4139: .l_base_pile), &((*l_bibliotheque_courante)
4140: .donnee)) == d_erreur)
4141: {
4142: # ifndef SEMAPHORES_NOMMES
4143: sem_post(&((*s_etat_processus).semaphore_fork));
4144: sem_destroy(&((*s_etat_processus)
4145: .semaphore_fork));
4146: # else
4147: sem_post((*s_etat_processus).semaphore_fork);
4148: sem_destroy3((*s_etat_processus).semaphore_fork,
4149: getpid(), pthread_self(), SEM_FORK);
4150: # endif
4151:
4152: liberation_contexte_cas(s_etat_processus);
4153: destruction_queue_signaux(s_etat_processus);
4154:
4155: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4156: stackoverflow_deinstall_handler();
4157: # endif
4158:
4159: # ifdef HAVE_SIGSEGV_RECOVERY
4160: if (debug == d_faux)
4161: {
4162: sigsegv_deinstall_handler();
4163: }
4164: # endif
4165:
4166: if ((*s_etat_processus).langue == 'F')
4167: {
4168: printf("+++Fatal :"
4169: " Chargement de la bibliothèse %s"
4170: " impossible\n", (unsigned char *)
4171: (*(*l_bibliotheque_courante).donnee)
4172: .objet);
4173: }
4174: else
4175: {
4176: printf("+++Fatal : Cannot load library %s\n",
4177: (*(*l_bibliotheque_courante).donnee)
4178: .objet);
4179: }
4180:
4181: if (traitement_fichier_temporaire == 'Y')
4182: {
4183: if (destruction_fichier(
4184: nom_fichier_temporaire)
4185: == d_erreur)
4186: {
4187: return(EXIT_FAILURE);
4188: }
4189:
4190: free(nom_fichier_temporaire);
4191: }
4192:
4193: return(EXIT_FAILURE);
4194: }
4195:
4196: l_bibliotheque_courante =
4197: (*l_bibliotheque_courante).suivant;
4198: }
4199:
1.1 bertrand 4200: if ((erreur = compilation(s_etat_processus)) !=
4201: d_absence_erreur)
4202: {
1.124 bertrand 4203: # ifndef SEMAPHORES_NOMMES
4204: sem_post(&((*s_etat_processus).semaphore_fork));
4205: sem_destroy(&((*s_etat_processus).semaphore_fork));
4206: # else
4207: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 4208: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 4209: getpid(), pthread_self(), SEM_FORK);
4210: # endif
4211:
4212: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4213: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4214:
4215: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4216: stackoverflow_deinstall_handler();
4217: # endif
4218:
4219: # ifdef HAVE_SIGSEGV_RECOVERY
4220: if (debug == d_faux)
4221: {
4222: sigsegv_deinstall_handler();
4223: }
4224: # endif
4225:
1.1 bertrand 4226: if (traitement_fichier_temporaire == 'Y')
4227: {
4228: if (destruction_fichier(nom_fichier_temporaire)
4229: == d_erreur)
4230: {
4231: return(EXIT_FAILURE);
4232: }
4233:
4234: free(nom_fichier_temporaire);
4235: }
4236:
4237: printf("%s [%d]\n", message =
4238: messages(s_etat_processus), (int) getpid());
4239: free(message);
4240:
4241: if (test_cfsf(s_etat_processus, 51) == d_faux)
4242: {
4243: printf("%s", ds_beep);
4244: }
4245:
4246: if ((*s_etat_processus).core == d_vrai)
4247: {
4248: printf("\n");
4249:
4250: if ((*s_etat_processus).langue == 'F')
4251: {
4252: printf("+++Information : Génération du fichier "
4253: "rpl-core [%d]\n", (int) getpid());
4254: }
4255: else
4256: {
4257: printf("+++Information : Writing rpl-core "
4258: "file [%d]\n", (int) getpid());
4259: }
4260:
4261: rplcore(s_etat_processus);
4262:
4263: if ((*s_etat_processus).langue == 'F')
4264: {
4265: printf("+++Information : Processus tracé "
4266: "[%d]\n", (int) getpid());
4267: }
4268: else
4269: {
4270: printf("+++Information : Done [%d]\n",
4271: (int) getpid());
4272: }
4273:
4274: printf("\n");
4275: }
4276:
4277: return(EXIT_FAILURE);
4278: }
4279:
4280: (*s_etat_processus).position_courante = 0;
4281: (*s_etat_processus).traitement_cycle_exit = 'N';
4282:
1.64 bertrand 4283: if ((*s_etat_processus).s_arbre_variables == NULL)
1.1 bertrand 4284: {
1.124 bertrand 4285: # ifndef SEMAPHORES_NOMMES
4286: sem_post(&((*s_etat_processus).semaphore_fork));
4287: sem_destroy(&((*s_etat_processus).semaphore_fork));
4288: # else
4289: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 4290: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 4291: getpid(), pthread_self(), SEM_FORK);
4292: # endif
4293:
4294: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4295: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4296:
4297: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4298: stackoverflow_deinstall_handler();
4299: # endif
4300:
4301: # ifdef HAVE_SIGSEGV_RECOVERY
4302: if (debug == d_faux)
4303: {
4304: sigsegv_deinstall_handler();
4305: }
4306: # endif
4307:
1.1 bertrand 4308: if ((*s_etat_processus).langue == 'F')
4309: {
4310: printf("+++Fatal : Aucun point d'entrée\n");
4311: }
4312: else
4313: {
4314: printf("+++Fatal : Any entry point\n");
4315: }
4316:
4317: if (test_cfsf(s_etat_processus, 51) == d_faux)
4318: {
4319: printf("%s", ds_beep);
4320: }
4321:
4322: return(EXIT_FAILURE);
4323: }
4324:
4325: if (recherche_instruction_suivante(s_etat_processus)
4326: == d_erreur)
4327: {
1.124 bertrand 4328: # ifndef SEMAPHORES_NOMMES
4329: sem_post(&((*s_etat_processus).semaphore_fork));
4330: sem_destroy(&((*s_etat_processus).semaphore_fork));
4331: # else
4332: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 4333: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 4334: getpid(), pthread_self(), SEM_FORK);
4335: # endif
4336:
4337: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4338: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4339:
4340: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4341: stackoverflow_deinstall_handler();
4342: # endif
4343:
4344: # ifdef HAVE_SIGSEGV_RECOVERY
4345: if (debug == d_faux)
4346: {
4347: sigsegv_deinstall_handler();
4348: }
4349: # endif
4350:
1.1 bertrand 4351: if ((*s_etat_processus).langue == 'F')
4352: {
4353: printf("+++Fatal : Aucun point d'entrée\n");
4354: }
4355: else
4356: {
4357: printf("+++Fatal : Any entry point\n");
4358: }
4359:
4360: if (test_cfsf(s_etat_processus, 51) == d_faux)
4361: {
4362: printf("%s", ds_beep);
4363: }
4364:
4365: return(EXIT_FAILURE);
4366: }
4367:
4368: if (recherche_variable(s_etat_processus,
4369: (*s_etat_processus)
4370: .instruction_courante) == d_faux)
4371: {
1.124 bertrand 4372: # ifndef SEMAPHORES_NOMMES
4373: sem_post(&((*s_etat_processus).semaphore_fork));
4374: sem_destroy(&((*s_etat_processus).semaphore_fork));
4375: # else
4376: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 4377: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 4378: getpid(), pthread_self(), SEM_FORK);
4379: # endif
4380:
4381: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4382: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4383:
4384: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4385: stackoverflow_deinstall_handler();
4386: # endif
4387:
4388: # ifdef HAVE_SIGSEGV_RECOVERY
4389: if (debug == d_faux)
4390: {
4391: sigsegv_deinstall_handler();
4392: }
4393: # endif
4394:
1.1 bertrand 4395: if ((*s_etat_processus).langue == 'F')
4396: {
4397: printf("+++Fatal : Aucun point d'entrée\n");
4398: }
4399: else
4400: {
4401: printf("+++Fatal : Any entry point\n");
4402: }
4403:
4404: if (test_cfsf(s_etat_processus, 51) == d_faux)
4405: {
4406: printf("%s", ds_beep);
4407: }
4408:
4409: return(EXIT_FAILURE);
4410: }
4411:
1.64 bertrand 4412: if ((*(*s_etat_processus).pointeur_variable_courante)
4413: .niveau != 0)
1.1 bertrand 4414: {
1.124 bertrand 4415: # ifndef SEMAPHORES_NOMMES
4416: sem_post(&((*s_etat_processus).semaphore_fork));
4417: sem_destroy(&((*s_etat_processus).semaphore_fork));
4418: # else
4419: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 4420: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 4421: getpid(), pthread_self(), SEM_FORK);
4422: # endif
4423:
4424: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4425: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4426:
4427: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4428: stackoverflow_deinstall_handler();
4429: # endif
4430:
4431: # ifdef HAVE_SIGSEGV_RECOVERY
4432: if (debug == d_faux)
4433: {
4434: sigsegv_deinstall_handler();
4435: }
4436: # endif
4437:
1.1 bertrand 4438: if ((*s_etat_processus).langue == 'F')
4439: {
4440: printf("+++Fatal : Aucun point d'entrée\n");
4441: }
4442: else
4443: {
4444: printf("+++Fatal : Any entry point\n");
4445: }
4446:
4447: if (test_cfsf(s_etat_processus, 51) == d_faux)
4448: {
4449: printf("%s", ds_beep);
4450: }
4451:
4452: return(EXIT_FAILURE);
4453: }
4454:
4455: free((*s_etat_processus).instruction_courante);
4456: (*s_etat_processus).position_courante = 0;
4457:
4458: if (((*s_etat_processus).nom_fichier_historique =
4459: malloc((strlen(home) +
4460: strlen(ds_fichier_historique) + 2) *
4461: sizeof(unsigned char))) == NULL)
4462: {
1.124 bertrand 4463: # ifndef SEMAPHORES_NOMMES
4464: sem_post(&((*s_etat_processus).semaphore_fork));
4465: sem_destroy(&((*s_etat_processus).semaphore_fork));
4466: # else
4467: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 4468: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 4469: getpid(), pthread_self(), SEM_FORK);
4470: # endif
4471:
4472: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4473: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4474:
4475: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4476: stackoverflow_deinstall_handler();
4477: # endif
4478:
4479: # ifdef HAVE_SIGSEGV_RECOVERY
4480: if (debug == d_faux)
4481: {
4482: sigsegv_deinstall_handler();
4483: }
4484: # endif
4485:
1.1 bertrand 4486: erreur = d_es_allocation_memoire;
4487:
4488: if ((*s_etat_processus).langue == 'F')
4489: {
4490: printf("+++Système : Mémoire insuffisante\n");
4491: }
4492: else
4493: {
4494: printf("+++System : Not enough memory\n");
4495: }
4496:
4497: return(EXIT_FAILURE);
4498: }
4499:
4500: sprintf((*s_etat_processus).nom_fichier_historique, "%s/%s",
4501: home, ds_fichier_historique);
4502:
4503: using_history();
1.109 bertrand 4504:
4505: // Pour pouvoir utiliser le keymap avant le premier
4506: // appel à readline().
4507: rl_initialize();
4508:
1.1 bertrand 4509: erreur_historique = read_history(
4510: (*s_etat_processus).nom_fichier_historique);
4511:
4512: gsl_set_error_handler(&traitement_exceptions_gsl);
4513:
4514: if (drapeau_encart == 'Y')
4515: {
4516: (*s_etat_processus).erreur_systeme = d_es;
4517: encart(s_etat_processus,
1.137 bertrand 4518: (integer8) (5 * 1000000));
1.1 bertrand 4519:
4520: if ((*s_etat_processus).erreur_systeme != d_es)
4521: {
4522: if ((message = messages(s_etat_processus))
4523: == NULL)
4524: {
1.124 bertrand 4525: # ifndef SEMAPHORES_NOMMES
4526: sem_post(&((*s_etat_processus)
4527: .semaphore_fork));
4528: sem_destroy(&((*s_etat_processus)
4529: .semaphore_fork));
4530: # else
4531: sem_post((*s_etat_processus)
4532: .semaphore_fork);
4533: sem_destroy3((*s_etat_processus)
1.155 bertrand 4534: .semaphore_fork,
1.124 bertrand 4535: getpid(), pthread_self(), SEM_FORK);
4536: # endif
4537:
4538: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4539: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4540:
4541: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4542: stackoverflow_deinstall_handler();
4543: # endif
4544:
4545: # ifdef HAVE_SIGSEGV_RECOVERY
4546: if (debug == d_faux)
4547: {
4548: sigsegv_deinstall_handler();
4549: }
4550: # endif
4551:
1.1 bertrand 4552: erreur = d_es_allocation_memoire;
4553:
4554: if ((*s_etat_processus).langue == 'F')
4555: {
4556: printf("+++Système : Mémoire "
4557: "insuffisante\n");
4558: }
4559: else
4560: {
4561: printf("+++System : Not enough "
4562: "memory\n");
4563: }
4564:
4565: return(EXIT_FAILURE);
4566: }
4567:
4568: printf("%s [%d]\n", message, (int) getpid());
4569: free(message);
4570:
4571: return(EXIT_FAILURE);
4572: }
4573: }
4574:
4575: fflush(stdout);
4576:
4577: if (arguments != NULL)
4578: {
4579: tampon = (*s_etat_processus).definitions_chainees;
4580: (*s_etat_processus).definitions_chainees =
4581: arguments;
4582:
4583: if (analyse_syntaxique(s_etat_processus) ==
4584: d_erreur)
4585: {
4586: if ((*s_etat_processus).erreur_systeme != d_es)
4587: {
1.124 bertrand 4588: # ifndef SEMAPHORES_NOMMES
4589: sem_post(&((*s_etat_processus)
4590: .semaphore_fork));
4591: sem_destroy(&((*s_etat_processus)
4592: .semaphore_fork));
4593: # else
4594: sem_post((*s_etat_processus)
4595: .semaphore_fork);
4596: sem_destroy3((*s_etat_processus)
1.155 bertrand 4597: .semaphore_fork,
1.124 bertrand 4598: getpid(), pthread_self(), SEM_FORK);
4599: # endif
4600:
4601: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4602: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4603:
4604: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4605: stackoverflow_deinstall_handler();
4606: # endif
4607:
4608: # ifdef HAVE_SIGSEGV_RECOVERY
4609: if (debug == d_faux)
4610: {
4611: sigsegv_deinstall_handler();
4612: }
4613: # endif
4614:
1.1 bertrand 4615: erreur = d_es_allocation_memoire;
4616:
4617: if ((*s_etat_processus).langue == 'F')
4618: {
4619: printf("+++Système : Mémoire "
4620: "insuffisante\n");
4621: }
4622: else
4623: {
4624: printf("+++System : Not enough "
4625: "memory\n");
4626: }
4627:
4628: return(EXIT_FAILURE);
4629: }
4630: else
4631: {
1.124 bertrand 4632: # ifndef SEMAPHORES_NOMMES
4633: sem_post(&((*s_etat_processus)
4634: .semaphore_fork));
4635: sem_destroy(&((*s_etat_processus)
4636: .semaphore_fork));
4637: # else
4638: sem_post((*s_etat_processus)
4639: .semaphore_fork);
4640: sem_destroy3((*s_etat_processus)
1.155 bertrand 4641: .semaphore_fork,
1.124 bertrand 4642: getpid(), pthread_self(), SEM_FORK);
4643: # endif
4644:
4645: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4646: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4647:
4648: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4649: stackoverflow_deinstall_handler();
4650: # endif
4651:
4652: # ifdef HAVE_SIGSEGV_RECOVERY
4653: if (debug == d_faux)
4654: {
4655: sigsegv_deinstall_handler();
4656: }
4657: # endif
4658:
1.1 bertrand 4659: if ((*s_etat_processus).langue == 'F')
4660: {
4661: printf("+++Erreur : Erreur de "
4662: "syntaxe\n");
4663: }
4664: else
4665: {
4666: printf("+++Error : Syntax error\n");
4667: }
4668:
4669: return(EXIT_FAILURE);
4670: }
4671: }
4672:
4673: (*s_etat_processus).instruction_courante
4674: = arguments;
4675: (*s_etat_processus).definitions_chainees = tampon;
4676: (*s_etat_processus).position_courante = 0;
4677:
1.160 bertrand 4678: (*s_etat_processus).type_en_cours = NON;
1.1 bertrand 4679: recherche_type(s_etat_processus);
4680:
4681: if ((*s_etat_processus).erreur_systeme != d_es)
4682: {
1.124 bertrand 4683: # ifndef SEMAPHORES_NOMMES
4684: sem_post(&((*s_etat_processus).semaphore_fork));
4685: sem_destroy(&((*s_etat_processus)
4686: .semaphore_fork));
4687: # else
4688: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 4689: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 4690: getpid(), pthread_self(), SEM_FORK);
4691: # endif
4692:
4693: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4694: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4695:
4696: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4697: stackoverflow_deinstall_handler();
4698: # endif
4699:
4700: # ifdef HAVE_SIGSEGV_RECOVERY
4701: if (debug == d_faux)
4702: {
4703: sigsegv_deinstall_handler();
4704: }
4705: # endif
4706:
1.1 bertrand 4707: if ((message = messages(s_etat_processus))
4708: == NULL)
4709: {
4710: erreur = d_es_allocation_memoire;
4711:
4712: if ((*s_etat_processus).langue == 'F')
4713: {
4714: printf("+++Système : Mémoire "
4715: "insuffisante\n");
4716: }
4717: else
4718: {
4719: printf("+++System : Not enough "
4720: "memory\n");
4721: }
4722:
4723: return(EXIT_FAILURE);
4724: }
4725:
4726: printf("%s [%d]\n", message, (int) getpid());
4727: free(message);
4728:
4729: return(EXIT_FAILURE);
4730: }
4731:
4732: if ((*s_etat_processus).erreur_execution != d_ex)
4733: {
4734: if ((message = messages(s_etat_processus))
4735: == NULL)
4736: {
1.124 bertrand 4737: # ifndef SEMAPHORES_NOMMES
4738: sem_post(&((*s_etat_processus)
4739: .semaphore_fork));
4740: sem_destroy(&((*s_etat_processus)
4741: .semaphore_fork));
4742: # else
4743: sem_post((*s_etat_processus)
4744: .semaphore_fork);
4745: sem_destroy3((*s_etat_processus)
1.155 bertrand 4746: .semaphore_fork,
1.124 bertrand 4747: getpid(), pthread_self(), SEM_FORK);
4748: # endif
4749:
4750: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4751: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4752:
4753: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4754: stackoverflow_deinstall_handler();
4755: # endif
4756:
4757: # ifdef HAVE_SIGSEGV_RECOVERY
4758: if (debug == d_faux)
4759: {
4760: sigsegv_deinstall_handler();
4761: }
4762: # endif
4763:
1.1 bertrand 4764: erreur = d_es_allocation_memoire;
4765:
4766: if ((*s_etat_processus).langue == 'F')
4767: {
4768: printf("+++Erreur : Mémoire "
4769: "insuffisante\n");
4770: }
4771: else
4772: {
4773: printf("+++Error : Not enough "
4774: "memory\n");
4775: }
4776:
4777: return(EXIT_FAILURE);
4778: }
4779:
4780: printf("%s [%d]\n", message, (int) getpid());
4781: free(message);
4782:
1.124 bertrand 4783: # ifndef SEMAPHORES_NOMMES
4784: sem_post(&((*s_etat_processus).semaphore_fork));
4785: sem_destroy(&((*s_etat_processus)
4786: .semaphore_fork));
4787: # else
4788: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 4789: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 4790: getpid(), pthread_self(), SEM_FORK);
4791: # endif
4792:
4793: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4794: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4795:
4796: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4797: stackoverflow_deinstall_handler();
4798: # endif
4799:
4800: # ifdef HAVE_SIGSEGV_RECOVERY
4801: if (debug == d_faux)
4802: {
4803: sigsegv_deinstall_handler();
4804: }
4805: # endif
4806:
1.1 bertrand 4807: return(EXIT_FAILURE);
4808: }
4809:
4810: if (depilement(s_etat_processus,
4811: &((*s_etat_processus).l_base_pile),
4812: &s_objet) == d_erreur)
4813: {
4814: if ((message = messages(s_etat_processus))
4815: == NULL)
4816: {
1.124 bertrand 4817: # ifndef SEMAPHORES_NOMMES
4818: sem_post(&((*s_etat_processus)
4819: .semaphore_fork));
4820: sem_destroy(&((*s_etat_processus)
4821: .semaphore_fork));
4822: # else
4823: sem_post((*s_etat_processus)
4824: .semaphore_fork);
4825: sem_destroy3((*s_etat_processus)
1.155 bertrand 4826: .semaphore_fork,
1.124 bertrand 4827: getpid(), pthread_self(), SEM_FORK);
4828: # endif
4829:
4830: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4831: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4832:
4833: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4834: stackoverflow_deinstall_handler();
4835: # endif
4836:
4837: # ifdef HAVE_SIGSEGV_RECOVERY
4838: if (debug == d_faux)
4839: {
4840: sigsegv_deinstall_handler();
4841: }
4842: # endif
4843:
4844: erreur = d_es_allocation_memoire;
1.1 bertrand 4845: erreur = d_es_allocation_memoire;
4846:
4847: if ((*s_etat_processus).langue == 'F')
4848: {
4849: printf("+++Erreur : Mémoire "
4850: "insuffisante\n");
4851: }
4852: else
4853: {
4854: printf("+++Error : Not enough "
4855: "memory\n");
4856: }
4857:
4858: return(EXIT_FAILURE);
4859: }
4860:
4861: printf("%s [%d]\n", message, (int) getpid());
4862: free(message);
4863:
1.124 bertrand 4864: # ifndef SEMAPHORES_NOMMES
4865: sem_post(&((*s_etat_processus).semaphore_fork));
4866: sem_destroy(&((*s_etat_processus)
4867: .semaphore_fork));
4868: # else
4869: sem_post((*s_etat_processus).semaphore_fork);
1.155 bertrand 4870: sem_destroy3((*s_etat_processus).semaphore_fork,
1.124 bertrand 4871: getpid(), pthread_self(), SEM_FORK);
4872: # endif
4873:
4874: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4875: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4876:
4877: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4878: stackoverflow_deinstall_handler();
4879: # endif
4880:
4881: # ifdef HAVE_SIGSEGV_RECOVERY
4882: if (debug == d_faux)
4883: {
4884: sigsegv_deinstall_handler();
4885: }
4886: # endif
4887:
1.1 bertrand 4888: return(EXIT_FAILURE);
4889: }
4890:
1.142 bertrand 4891: empilement_pile_systeme(s_etat_processus);
4892:
1.1 bertrand 4893: if (evaluation(s_etat_processus, s_objet, 'E')
4894: == d_erreur)
4895: {
4896: if ((*s_etat_processus).erreur_systeme != d_es)
4897: {
4898: if ((message = messages(s_etat_processus))
4899: == NULL)
4900: {
1.124 bertrand 4901: # ifndef SEMAPHORES_NOMMES
4902: sem_post(&((*s_etat_processus)
4903: .semaphore_fork));
4904: sem_destroy(&((*s_etat_processus)
4905: .semaphore_fork));
4906: # else
4907: sem_post((*s_etat_processus)
4908: .semaphore_fork);
4909: sem_destroy3((*s_etat_processus)
1.155 bertrand 4910: .semaphore_fork, getpid(),
1.124 bertrand 4911: pthread_self(), SEM_FORK);
4912: # endif
4913:
4914: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4915: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4916:
4917: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4918: stackoverflow_deinstall_handler();
4919: # endif
4920:
4921: # ifdef HAVE_SIGSEGV_RECOVERY
4922: if (debug == d_faux)
4923: {
4924: sigsegv_deinstall_handler();
4925: }
4926: # endif
4927:
1.1 bertrand 4928: erreur = d_es_allocation_memoire;
4929:
4930: if ((*s_etat_processus).langue == 'F')
4931: {
4932: printf("+++Système : Mémoire "
4933: "insuffisante\n");
4934: }
4935: else
4936: {
4937: printf("+++System : Not enough "
4938: "memory\n");
4939: }
4940:
4941: return(EXIT_FAILURE);
4942: }
4943:
4944: printf("%s [%d]\n", message,
4945: (int) getpid());
4946: free(message);
4947:
1.124 bertrand 4948: # ifndef SEMAPHORES_NOMMES
4949: sem_post(&((*s_etat_processus)
4950: .semaphore_fork));
4951: sem_destroy(&((*s_etat_processus)
4952: .semaphore_fork));
4953: # else
4954: sem_post((*s_etat_processus)
4955: .semaphore_fork);
4956: sem_destroy3((*s_etat_processus)
1.155 bertrand 4957: .semaphore_fork,
1.124 bertrand 4958: getpid(), pthread_self(), SEM_FORK);
4959: # endif
4960:
4961: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4962: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 4963:
4964: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
4965: stackoverflow_deinstall_handler();
4966: # endif
4967:
4968: # ifdef HAVE_SIGSEGV_RECOVERY
4969: if (debug == d_faux)
4970: {
4971: sigsegv_deinstall_handler();
4972: }
4973: # endif
4974:
4975: erreur = d_es_allocation_memoire;
1.1 bertrand 4976: return(EXIT_FAILURE);
4977: }
4978:
4979: if ((*s_etat_processus).erreur_execution
4980: != d_ex)
4981: {
4982: if ((message = messages(s_etat_processus))
4983: == NULL)
4984: {
1.124 bertrand 4985: # ifndef SEMAPHORES_NOMMES
4986: sem_post(&((*s_etat_processus)
4987: .semaphore_fork));
4988: sem_destroy(&((*s_etat_processus)
4989: .semaphore_fork));
4990: # else
4991: sem_post((*s_etat_processus)
4992: .semaphore_fork);
4993: sem_destroy3((*s_etat_processus)
1.155 bertrand 4994: .semaphore_fork, getpid(),
1.124 bertrand 4995: pthread_self(), SEM_FORK);
4996: # endif
4997:
4998: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 4999: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 5000:
5001: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
5002: stackoverflow_deinstall_handler();
5003: # endif
5004:
5005: # ifdef HAVE_SIGSEGV_RECOVERY
5006: if (debug == d_faux)
5007: {
5008: sigsegv_deinstall_handler();
5009: }
5010: # endif
5011:
1.1 bertrand 5012: erreur = d_es_allocation_memoire;
5013:
5014: if ((*s_etat_processus).langue == 'F')
5015: {
5016: printf("+++Erreur : Mémoire "
5017: "insuffisante\n");
5018: }
5019: else
5020: {
5021: printf("+++Error : Not enough "
5022: "memory\n");
5023: }
5024:
5025: return(EXIT_FAILURE);
5026: }
5027:
5028: printf("%s [%d]\n", message,
5029: (int) getpid());
5030: free(message);
5031:
1.124 bertrand 5032: # ifndef SEMAPHORES_NOMMES
5033: sem_post(&((*s_etat_processus)
5034: .semaphore_fork));
5035: sem_destroy(&((*s_etat_processus)
5036: .semaphore_fork));
5037: # else
5038: sem_post((*s_etat_processus)
5039: .semaphore_fork);
5040: sem_destroy3((*s_etat_processus)
1.155 bertrand 5041: .semaphore_fork,
1.124 bertrand 5042: getpid(), pthread_self(), SEM_FORK);
5043: # endif
5044:
5045: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 5046: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 5047:
5048: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
5049: stackoverflow_deinstall_handler();
5050: # endif
5051:
5052: # ifdef HAVE_SIGSEGV_RECOVERY
5053: if (debug == d_faux)
5054: {
5055: sigsegv_deinstall_handler();
5056: }
5057: # endif
5058:
1.1 bertrand 5059: return(EXIT_FAILURE);
5060: }
5061: }
5062:
5063: (*s_etat_processus).instruction_courante = NULL;
5064: liberation(s_etat_processus, s_objet);
5065:
5066: free(arguments);
5067: }
5068:
1.13 bertrand 5069: if (option_a == d_vrai)
1.1 bertrand 5070: {
1.13 bertrand 5071: fprintf(stdout, "%s\n", (*s_etat_processus)
5072: .definitions_chainees);
1.1 bertrand 5073: }
1.13 bertrand 5074: else
5075: {
5076: if (option_D == d_vrai)
5077: {
5078: lancement_daemon(s_etat_processus);
5079: }
1.1 bertrand 5080:
1.13 bertrand 5081: if (option_p == d_faux)
1.1 bertrand 5082: {
1.13 bertrand 5083: if (setjmp(contexte_initial) == 0)
5084: {
5085: erreur = sequenceur(s_etat_processus);
1.80 bertrand 5086:
5087: if (erreur == d_absence_erreur)
5088: {
1.138 bertrand 5089: if (((*s_etat_processus)
1.80 bertrand 5090: .arret_depuis_abort == 0) &&
5091: ((*s_etat_processus).at_exit
5092: != NULL))
5093: {
1.138 bertrand 5094: // Permet de traiter ATEXIT
5095: // même après réception d'un SIGINT.
5096: (*s_etat_processus)
5097: .var_volatile_alarme = 0;
5098: (*s_etat_processus)
5099: .var_volatile_requete_arret = 0;
5100:
1.139 bertrand 5101: if ((*s_etat_processus).profilage ==
5102: d_vrai)
5103: {
5104: profilage(s_etat_processus,
5105: "ATEXIT");
5106: }
5107:
1.80 bertrand 5108: erreur = evaluation(s_etat_processus,
5109: (*s_etat_processus).at_exit,
5110: 'E');
1.139 bertrand 5111:
5112: if ((*s_etat_processus).profilage ==
5113: d_vrai)
5114: {
5115: profilage(s_etat_processus, NULL);
5116: }
5117:
5118: if (((*s_etat_processus)
5119: .erreur_execution != d_ex) ||
5120: ((*s_etat_processus).exception
5121: != d_ep) || ((*s_etat_processus)
5122: .erreur_systeme != d_es))
5123: {
5124: printf("%s [%d]\n", message =
5125: messages(s_etat_processus),
5126: (int) getpid());
5127: free(message);
5128:
5129: if (test_cfsf(s_etat_processus, 51)
5130: == d_faux)
5131: {
5132: printf("%s", ds_beep);
5133: }
5134:
5135: if ((*s_etat_processus).core ==
5136: d_vrai)
5137: {
5138: printf("\n");
5139:
5140: if ((*s_etat_processus).langue
5141: == 'F')
5142: {
5143: printf("+++Information : Gé"
5144: "nération du fichie"
5145: "r rpl-core "
5146: "[%d]\n", (int)
5147: getpid());
5148: }
5149: else
5150: {
5151: printf("+++Information : Wr"
5152: "iting rpl-core fil"
5153: "e [%d]\n",
5154: (int) getpid());
5155: }
5156:
5157: rplcore(s_etat_processus);
5158:
5159: if ((*s_etat_processus).langue
5160: == 'F')
5161: {
5162: printf("+++Information : Pr"
5163: "ocessus tracé [%d]"
5164: "\n",
5165: (int) getpid());
5166: }
5167: else
5168: {
5169: printf("+++Information : Do"
5170: "ne [%d]\n", (int)
5171: getpid());
5172: }
5173:
5174: printf("\n");
5175: fflush(stdout);
5176: }
5177: }
1.80 bertrand 5178: }
5179: }
1.13 bertrand 5180: }
1.1 bertrand 5181: }
1.13 bertrand 5182: else
1.1 bertrand 5183: {
1.13 bertrand 5184: if (setjmp(contexte_initial) == 0)
5185: {
1.195 bertrand 5186: erreur = sequenceur_optimise(s_etat_processus,
5187: l_bibliotheques);
1.19 bertrand 5188:
1.80 bertrand 5189: if (erreur == d_absence_erreur)
5190: {
1.138 bertrand 5191: if (((*s_etat_processus)
1.80 bertrand 5192: .arret_depuis_abort == 0) &&
5193: ((*s_etat_processus).at_exit
5194: != NULL))
5195: {
1.138 bertrand 5196: // Permet de traiter ATEXIT
5197: // même après réception d'un SIGINT.
5198: (*s_etat_processus)
5199: .var_volatile_alarme = 0;
5200: (*s_etat_processus)
5201: .var_volatile_requete_arret = 0;
5202:
1.139 bertrand 5203: if ((*s_etat_processus).profilage ==
5204: d_vrai)
5205: {
5206: profilage(s_etat_processus,
5207: "ATEXIT");
5208: }
5209:
1.80 bertrand 5210: erreur = evaluation(s_etat_processus,
5211: (*s_etat_processus).at_exit,
5212: 'E');
1.139 bertrand 5213:
5214: if ((*s_etat_processus).profilage ==
5215: d_vrai)
5216: {
5217: profilage(s_etat_processus, NULL);
5218: }
5219:
5220: if (((*s_etat_processus)
5221: .erreur_execution != d_ex) ||
5222: ((*s_etat_processus).exception
5223: != d_ep) || ((*s_etat_processus)
5224: .erreur_systeme != d_es))
5225: {
5226: printf("%s [%d]\n", message =
5227: messages(s_etat_processus),
5228: (int) getpid());
5229: free(message);
5230:
5231: if (test_cfsf(s_etat_processus, 51)
5232: == d_faux)
5233: {
5234: printf("%s", ds_beep);
5235: }
5236:
5237: if ((*s_etat_processus).core ==
5238: d_vrai)
5239: {
5240: printf("\n");
5241:
5242: if ((*s_etat_processus).langue
5243: == 'F')
5244: {
5245: printf("+++Information : Gé"
5246: "nération du fichie"
5247: "r rpl-core "
5248: "[%d]\n", (int)
5249: getpid());
5250: }
5251: else
5252: {
5253: printf("+++Information : Wr"
5254: "iting rpl-core fil"
5255: "e [%d]\n",
5256: (int) getpid());
5257: }
5258:
5259: rplcore(s_etat_processus);
5260:
5261: if ((*s_etat_processus).langue
5262: == 'F')
5263: {
5264: printf("+++Information : Pr"
5265: "ocessus tracé [%d]"
5266: "\n",
5267: (int) getpid());
5268: }
5269: else
5270: {
5271: printf("+++Information : Do"
5272: "ne [%d]\n", (int)
5273: getpid());
5274: }
5275:
5276: printf("\n");
5277: fflush(stdout);
5278: }
5279: }
1.80 bertrand 5280: }
5281: }
1.21 bertrand 5282: }
1.19 bertrand 5283: }
1.34 bertrand 5284: }
1.19 bertrand 5285:
1.117 bertrand 5286: for(i = 0; i < (*s_etat_processus).sections_critiques; i++)
5287: {
5288: pthread_mutex_unlock(&mutex_sections_critiques);
5289: }
5290:
1.34 bertrand 5291: liberation(s_etat_processus, (*s_etat_processus).at_exit);
5292: liberation(s_etat_processus, (*s_etat_processus).at_poke);
1.1 bertrand 5293:
5294: if ((*s_etat_processus).generateur_aleatoire != NULL)
5295: {
5296: liberation_generateur_aleatoire(s_etat_processus);
5297: }
5298:
5299: l_element_courant = (*s_etat_processus).liste_mutexes;
5300: while(l_element_courant != NULL)
5301: {
5302: liberation(s_etat_processus,
5303: (*((struct_liste_chainee *)
5304: l_element_courant)).donnee);
5305: l_element_suivant = (*((struct_liste_chainee *)
5306: l_element_courant)).suivant;
5307: free((struct_liste_chainee *) l_element_courant);
5308: l_element_courant = l_element_suivant;
5309: }
5310:
5311: /*
5312: * Arrêt des processus fils
5313: */
5314:
5315: if ((*s_etat_processus).presence_fusible == d_vrai)
5316: {
5317: pthread_cancel((*s_etat_processus).thread_fusible);
5318: }
5319:
1.146 bertrand 5320: pthread_mutex_lock(&((*s_etat_processus)
5321: .mutex_pile_processus));
1.1 bertrand 5322:
5323: l_element_courant = (void *) (*s_etat_processus)
5324: .l_base_pile_processus;
5325:
5326: while(l_element_courant != NULL)
5327: {
5328: if ((*s_etat_processus).debug == d_vrai)
5329: {
5330: if (((*s_etat_processus).type_debug &
5331: d_debug_processus) != 0)
5332: {
5333: if ((*(*((struct_processus_fils *)
5334: (*(*((struct_liste_chainee *)
5335: l_element_courant)).donnee)
5336: .objet)).thread)
5337: .processus_detache == d_vrai)
5338: {
5339: if ((*s_etat_processus).langue == 'F')
5340: {
5341: printf("[%d] Signalement pour arrêt du "
5342: "processus %d\n",
5343: (int) getpid(), (int)
5344: (*(*((struct_processus_fils *)
5345: (*(*((struct_liste_chainee *)
5346: l_element_courant)).donnee)
5347: .objet)).thread).pid);
5348: }
5349: else
5350: {
5351: printf("[%d] Send stop signal to "
5352: "process %d\n",
5353: (int) getpid(), (int)
5354: (*(*((struct_processus_fils *)
5355: (*(*((struct_liste_chainee *)
5356: l_element_courant)).donnee)
5357: .objet)).thread).pid);
5358: }
5359: }
5360: else
5361: {
5362: if ((*s_etat_processus).langue == 'F')
5363: {
5364: printf("[%d] Signalement pour arrêt du "
5365: "thread %llu\n", (int) getpid(),
5366: (unsigned long long)
5367: (*(*((struct_processus_fils *)
5368: (*(*((struct_liste_chainee *)
5369: l_element_courant)).donnee)
5370: .objet)).thread).tid);
5371: }
5372: else
5373: {
5374: printf("[%d] Send stop signal to "
5375: "thread %llu\n",
5376: (int) getpid(),
5377: (unsigned long long)
5378: (*(*((struct_processus_fils *)
5379: (*(*((struct_liste_chainee *)
5380: l_element_courant)).donnee)
5381: .objet)).thread).tid);
5382: }
5383: }
5384: }
5385: }
5386:
5387: if ((*(*((struct_processus_fils *)
5388: (*(*((struct_liste_chainee *)
5389: l_element_courant)).donnee).objet))
5390: .thread).processus_detache == d_vrai)
5391: {
5392: if ((*s_etat_processus).var_volatile_alarme != 0)
5393: {
1.83 bertrand 5394: envoi_signal_processus(
5395: (*(*((struct_processus_fils *)
1.1 bertrand 5396: (*(*((struct_liste_chainee *)
5397: l_element_courant)).donnee).objet))
1.180 bertrand 5398: .thread).pid, rpl_sigurg, d_faux);
1.1 bertrand 5399: }
5400: else
5401: {
1.22 bertrand 5402: if ((*s_etat_processus).arret_depuis_abort
5403: == -1)
5404: {
1.83 bertrand 5405: envoi_signal_processus(
5406: (*(*((struct_processus_fils *)
1.22 bertrand 5407: (*(*((struct_liste_chainee *)
5408: l_element_courant)).donnee).objet))
1.180 bertrand 5409: .thread).pid, rpl_sigabort, d_faux);
1.22 bertrand 5410: }
5411: else
5412: {
1.83 bertrand 5413: envoi_signal_processus(
5414: (*(*((struct_processus_fils *)
1.22 bertrand 5415: (*(*((struct_liste_chainee *)
5416: l_element_courant)).donnee).objet))
1.180 bertrand 5417: .thread).pid, rpl_sigstop, d_faux);
1.22 bertrand 5418: }
1.1 bertrand 5419: }
5420: }
5421: else
5422: {
5423: pthread_mutex_lock(&((*(*((struct_processus_fils *)
5424: (*(*((struct_liste_chainee *)
5425: l_element_courant)).donnee).objet)).thread)
5426: .mutex));
5427:
5428: if ((*(*((struct_processus_fils *)
5429: (*(*((struct_liste_chainee *)
5430: l_element_courant)).donnee).objet)).thread)
5431: .thread_actif == d_vrai)
5432: {
5433: if ((*s_etat_processus).var_volatile_alarme
5434: != 0)
5435: {
1.83 bertrand 5436: envoi_signal_thread(
5437: (*(*((struct_processus_fils *)
1.1 bertrand 5438: (*(*((struct_liste_chainee *)
5439: l_element_courant)).donnee).objet))
1.83 bertrand 5440: .thread).tid, rpl_sigurg);
1.1 bertrand 5441: }
5442: else
5443: {
1.22 bertrand 5444: if ((*s_etat_processus).arret_depuis_abort
5445: == -1)
5446: {
1.83 bertrand 5447: envoi_signal_thread(
1.22 bertrand 5448: (*(*((struct_processus_fils *)
5449: (*(*((struct_liste_chainee *)
5450: l_element_courant)).donnee)
5451: .objet)).thread).tid,
1.83 bertrand 5452: rpl_sigabort);
1.22 bertrand 5453: }
5454: else
5455: {
1.83 bertrand 5456: envoi_signal_thread(
1.22 bertrand 5457: (*(*((struct_processus_fils *)
5458: (*(*((struct_liste_chainee *)
5459: l_element_courant)).donnee)
5460: .objet)).thread).tid,
1.83 bertrand 5461: rpl_sigstop);
1.22 bertrand 5462: }
1.1 bertrand 5463: }
5464: }
5465:
5466: pthread_mutex_unlock(
5467: &((*(*((struct_processus_fils *)
5468: (*(*((struct_liste_chainee *)
5469: l_element_courant)).donnee).objet)).thread)
5470: .mutex));
5471: }
5472:
5473: l_element_courant = (*((struct_liste_chainee *)
5474: l_element_courant)).suivant;
5475: }
5476:
5477: /*
5478: * Attente de la fin de tous les processus fils
5479: */
5480:
5481: for(i = 0; i < d_NOMBRE_INTERRUPTIONS;
5482: (*s_etat_processus).masque_interruptions[i++]
5483: = 'I');
5484:
5485: attente.tv_sec = 0;
5486: attente.tv_nsec = GRANULARITE_us * 1000;
5487:
5488: while((*s_etat_processus).l_base_pile_processus != NULL)
5489: {
5490: l_element_courant = (void *)
5491: (*s_etat_processus).l_base_pile_processus;
5492:
1.136 bertrand 5493: for(i = 0; i < (*(*((struct_processus_fils *)
1.1 bertrand 5494: (*(*((struct_liste_chainee *)
5495: l_element_courant)).donnee).objet)).thread)
5496: .nombre_objets_dans_pipe; i++)
5497: {
5498: if ((s_objet = lecture_pipe(
5499: s_etat_processus,
5500: (*(*((struct_processus_fils *)
5501: (*(*((struct_liste_chainee *)
5502: l_element_courant)).donnee).objet)).thread)
5503: .pipe_objets[0])) != NULL)
5504: {
5505: liberation(s_etat_processus, s_objet);
5506:
5507: (*(*((struct_processus_fils *)
5508: (*(*((struct_liste_chainee *)
5509: l_element_courant)).donnee).objet))
5510: .thread).nombre_objets_dans_pipe--;
5511:
5512: action.sa_handler = SIG_IGN;
1.94 bertrand 5513: action.sa_flags = 0;
1.1 bertrand 5514:
5515: if (sigaction(SIGPIPE, &action, ®istre)
5516: != 0)
5517: {
1.124 bertrand 5518: # ifndef SEMAPHORES_NOMMES
5519: sem_post(&((*s_etat_processus)
5520: .semaphore_fork));
5521: sem_destroy(&((*s_etat_processus)
5522: .semaphore_fork));
5523: # else
5524: sem_post((*s_etat_processus)
5525: .semaphore_fork);
5526: sem_destroy3((*s_etat_processus)
1.155 bertrand 5527: .semaphore_fork, getpid(),
1.124 bertrand 5528: pthread_self(), SEM_FORK);
5529: # endif
5530:
5531: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 5532: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 5533:
5534: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
5535: stackoverflow_deinstall_handler();
5536: # endif
5537:
5538: # ifdef HAVE_SIGSEGV_RECOVERY
5539: if (debug == d_faux)
5540: {
5541: sigsegv_deinstall_handler();
5542: }
5543: # endif
5544:
1.146 bertrand 5545: pthread_mutex_unlock(&((*s_etat_processus)
5546: .mutex_pile_processus));
1.1 bertrand 5547: return(EXIT_FAILURE);
5548: }
5549:
5550: while((longueur_ecriture =
5551: write_atomic(s_etat_processus,
5552: (*(*((struct_processus_fils *)
5553: (*(*((struct_liste_chainee *)
5554: l_element_courant)).donnee).objet))
5555: .thread).pipe_nombre_injections[1], "+",
5556: sizeof(unsigned char))) !=
5557: sizeof(unsigned char))
5558: {
5559: if (longueur_ecriture == -1)
5560: {
5561: // Le processus n'existe plus.
5562: break;
5563: }
5564: }
5565:
5566: if (sigaction(SIGPIPE, ®istre, NULL)
5567: != 0)
5568: {
1.124 bertrand 5569: # ifndef SEMAPHORES_NOMMES
5570: sem_post(&((*s_etat_processus)
5571: .semaphore_fork));
5572: sem_destroy(&((*s_etat_processus)
5573: .semaphore_fork));
5574: # else
5575: sem_post((*s_etat_processus)
5576: .semaphore_fork);
5577: sem_destroy3((*s_etat_processus)
1.155 bertrand 5578: .semaphore_fork, getpid(),
1.124 bertrand 5579: pthread_self(), SEM_FORK);
5580: # endif
5581:
5582: liberation_contexte_cas(s_etat_processus);
1.161 bertrand 5583: destruction_queue_signaux(s_etat_processus);
1.124 bertrand 5584:
5585: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
5586: stackoverflow_deinstall_handler();
5587: # endif
5588:
5589: # ifdef HAVE_SIGSEGV_RECOVERY
5590: if (debug == d_faux)
5591: {
5592: sigsegv_deinstall_handler();
5593: }
5594: # endif
5595:
1.146 bertrand 5596: pthread_mutex_unlock(&((*s_etat_processus)
5597: .mutex_pile_processus));
1.1 bertrand 5598: return(EXIT_FAILURE);
5599: }
5600: }
5601: }
5602:
1.145 bertrand 5603: pthread_mutex_lock(&((*s_etat_processus)
5604: .mutex_interruptions));
5605:
1.23 bertrand 5606: if ((*s_etat_processus)
5607: .nombre_interruptions_non_affectees != 0)
5608: {
5609: affectation_interruptions_logicielles(
5610: s_etat_processus);
5611: }
5612:
1.145 bertrand 5613: pthread_mutex_unlock(&((*s_etat_processus)
5614: .mutex_interruptions));
1.146 bertrand 5615: pthread_mutex_unlock(&((*s_etat_processus)
5616: .mutex_pile_processus));
1.1 bertrand 5617: nanosleep(&attente, NULL);
1.85 bertrand 5618: scrutation_interruptions(s_etat_processus);
1.146 bertrand 5619: pthread_mutex_lock(&((*s_etat_processus)
5620: .mutex_pile_processus));
1.1 bertrand 5621: }
5622:
1.146 bertrand 5623: pthread_mutex_unlock(&((*s_etat_processus)
5624: .mutex_pile_processus));
1.1 bertrand 5625:
5626: erreur_historique = write_history(
5627: (*s_etat_processus).nom_fichier_historique);
5628: clear_history();
5629:
5630: if (erreur_historique != 0)
5631: {
5632: if ((*s_etat_processus).langue == 'F')
5633: {
5634: printf("+++Erreur : L'historique ne peut être "
5635: "écrit\n");
5636: }
5637: else
5638: {
5639: printf("+++Error : History cannot be "
5640: "written\n");
5641: }
5642:
5643: if (test_cfsf(s_etat_processus, 51) == d_faux)
5644: {
5645: printf("%s", ds_beep);
5646: }
5647: }
5648:
5649: free((*s_etat_processus).nom_fichier_historique);
5650:
5651: if (((*s_etat_processus).core == d_vrai) &&
5652: (erreur == d_erreur) &&
5653: ((*s_etat_processus).var_volatile_traitement_sigint
5654: == 0))
5655: {
5656: printf("\n");
5657:
5658: if ((*s_etat_processus).langue == 'F')
5659: {
5660: printf("+++Information : Génération du fichier "
5661: "rpl-core [%d]\n", (int) getpid());
5662: }
5663: else
5664: {
5665: printf("+++Information : Writing rpl-core "
5666: "file [%d]\n", (int) getpid());
5667: }
5668:
5669: rplcore(s_etat_processus);
5670:
5671: if ((*s_etat_processus).langue == 'F')
5672: {
5673: printf("+++Information : Processus tracé [%d]\n",
5674: (int) getpid());
5675: }
5676: else
5677: {
5678: printf("+++Information : Done [%d]\n",
5679: (int) getpid());
5680: }
5681:
5682: printf("\n");
5683: }
5684:
5685: free((*s_etat_processus).definitions_chainees);
5686:
5687: /*
5688: * Libération de l'arbre des instructions
5689: */
5690:
5691: liberation_arbre_instructions(s_etat_processus,
5692: (*s_etat_processus).arbre_instructions);
5693: free((*s_etat_processus).pointeurs_caracteres);
5694:
5695: if ((*s_etat_processus).entree_standard != NULL)
5696: {
5697: pclose((*s_etat_processus).entree_standard);
5698: (*s_etat_processus).entree_standard = NULL;
5699: }
5700:
5701: if ((*s_etat_processus).nom_fichier_impression != NULL)
5702: {
5703: if (test_cfsf(s_etat_processus, 51) == d_faux)
5704: {
5705: printf("%s", ds_beep);
5706: }
5707:
5708: if ((*s_etat_processus).langue == 'F')
5709: {
5710: printf("+++Attention : Queue d'impression "
5711: "non vide !\n");
5712: }
5713: else
5714: {
5715: printf("+++Warning : Non empty printing "
5716: "spool queue !\n");
5717: }
5718:
5719: instruction_erase(s_etat_processus);
5720: }
5721:
5722: if ((*s_etat_processus).fichiers_graphiques != NULL)
5723: {
5724: instruction_cllcd(s_etat_processus);
5725: }
5726:
5727: liberation(s_etat_processus, (*s_etat_processus).indep);
5728: liberation(s_etat_processus, (*s_etat_processus).depend);
5729:
5730: free((*s_etat_processus).label_x);
5731: free((*s_etat_processus).label_y);
5732: free((*s_etat_processus).label_z);
5733: free((*s_etat_processus).titre);
5734: free((*s_etat_processus).legende);
5735:
5736: liberation(s_etat_processus, (*s_etat_processus)
5737: .parametres_courbes_de_niveau);
5738:
5739: for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
5740: {
5741: liberation(s_etat_processus,
5742: (*s_etat_processus).corps_interruptions[i]);
5743:
5744: l_element_courant = (*s_etat_processus)
5745: .pile_origine_interruptions[i];
5746:
5747: while(l_element_courant != NULL)
5748: {
5749: l_element_suivant = (*((struct_liste_chainee *)
5750: l_element_courant)).suivant;
5751:
5752: liberation(s_etat_processus,
5753: (*((struct_liste_chainee *)
5754: l_element_courant)).donnee);
5755: free(l_element_courant);
5756:
5757: l_element_courant = l_element_suivant;
5758: }
5759: }
5760:
5761: if ((*s_etat_processus).instruction_derniere_erreur
5762: != NULL)
5763: {
5764: free((*s_etat_processus).instruction_derniere_erreur);
5765: (*s_etat_processus).instruction_derniere_erreur = NULL;
5766: }
5767:
5768: /*
5769: * Le pointeur s_etat_processus.nom_fichier_source est
5770: * alloué par le système. Il ne faut donc pas
5771: * le libérer...
5772: */
5773:
1.125 bertrand 5774: liberation_arbre_variables_partagees(s_etat_processus,
1.127 bertrand 5775: (*(*s_etat_processus).s_arbre_variables_partagees));
1.66 bertrand 5776: liberation_arbre_variables(s_etat_processus,
5777: (*s_etat_processus).s_arbre_variables, d_vrai);
5778: free((*s_etat_processus).pointeurs_caracteres_variables);
1.1 bertrand 5779:
1.121 bertrand 5780: l_element_statique_courant = (*s_etat_processus)
5781: .l_liste_variables_statiques;
5782:
5783: while(l_element_statique_courant != NULL)
5784: {
5785: l_element_statique_suivant =
5786: (*l_element_statique_courant).suivant;
5787: free(l_element_statique_courant);
5788: l_element_statique_courant = l_element_statique_suivant;
5789: }
5790:
1.127 bertrand 5791: l_element_partage_courant = (*(*s_etat_processus)
5792: .l_liste_variables_partagees);
5793:
5794: while(l_element_partage_courant != NULL)
5795: {
5796: l_element_partage_suivant =
5797: (*l_element_partage_courant).suivant;
5798: free(l_element_partage_courant);
5799: l_element_partage_courant = l_element_partage_suivant;
5800: }
5801:
1.1 bertrand 5802: /*
5803: * Si resultats est non nul, rplinit a été appelé
5804: * depuis rpl() [librpl] et non main().
5805: * On copie alors le contenu de la * pile dans un
5806: * tableau **resultats dont le pointeur de base a
5807: * été alloué dans rpl().
5808: */
5809:
5810: if (resultats != NULL)
5811: {
5812: if ((*resultats) != NULL)
5813: {
1.171 bertrand 5814: sys_free((*resultats));
1.1 bertrand 5815:
1.171 bertrand 5816: if (((*resultats) = sys_malloc(((size_t)
1.136 bertrand 5817: ((*s_etat_processus)
5818: .hauteur_pile_operationnelle + 1))
1.1 bertrand 5819: * sizeof(unsigned char **))) != NULL)
5820: {
5821: (*resultats)[(*s_etat_processus)
5822: .hauteur_pile_operationnelle] = NULL;
5823: l_element_courant = (void *) (*s_etat_processus)
5824: .l_base_pile;
5825:
5826: for(i = 0; i < (*s_etat_processus)
5827: .hauteur_pile_operationnelle; i++)
5828: {
5829: if (l_element_courant != NULL)
5830: {
5831: (*resultats)[i] =
5832: formateur(s_etat_processus,
5833: 0, (*((struct_liste_chainee *)
5834: l_element_courant)).donnee);
5835:
5836: if ((*resultats)[i] == NULL)
5837: {
5838: i = (*s_etat_processus).
5839: hauteur_pile_operationnelle;
5840: }
5841: else
5842: {
5843: l_element_suivant =
5844: (*((struct_liste_chainee *)
5845: l_element_courant)).suivant;
5846: }
5847: }
5848: }
5849: }
5850: else
5851: {
5852: (*resultats) = NULL;
5853: erreur = d_es_allocation_memoire;
5854: }
5855: }
5856: }
5857:
5858: l_element_courant = (void *) (*s_etat_processus)
5859: .l_base_pile;
5860: while(l_element_courant != NULL)
5861: {
5862: l_element_suivant = (*((struct_liste_chainee *)
5863: l_element_courant)).suivant;
5864:
5865: liberation(s_etat_processus,
5866: (*((struct_liste_chainee *)
5867: l_element_courant)).donnee);
5868: free((struct_liste_chainee *) l_element_courant);
5869:
5870: l_element_courant = l_element_suivant;
5871: }
5872:
5873: l_element_courant = (void *) (*s_etat_processus)
5874: .l_base_pile_contextes;
5875: while(l_element_courant != NULL)
5876: {
5877: l_element_suivant = (*((struct_liste_chainee *)
5878: l_element_courant)).suivant;
5879:
5880: liberation(s_etat_processus,
5881: (*((struct_liste_chainee *)
5882: l_element_courant)).donnee);
5883: free((struct_liste_chainee *) l_element_courant);
5884:
5885: l_element_courant = l_element_suivant;
5886: }
5887:
5888: l_element_courant = (void *) (*s_etat_processus)
5889: .l_base_pile_taille_contextes;
5890: while(l_element_courant != NULL)
5891: {
5892: l_element_suivant = (*((struct_liste_chainee *)
5893: l_element_courant)).suivant;
5894:
5895: liberation(s_etat_processus,
5896: (*((struct_liste_chainee *)
5897: l_element_courant)).donnee);
5898: free((struct_liste_chainee *) l_element_courant);
5899:
5900: l_element_courant = l_element_suivant;
5901: }
5902:
5903: l_element_courant = (void *) (*s_etat_processus)
1.197 bertrand 5904: .l_base_pile_last;
1.1 bertrand 5905: while(l_element_courant != NULL)
5906: {
5907: l_element_suivant = (*((struct_liste_chainee *)
5908: l_element_courant)).suivant;
5909:
1.197 bertrand 5910: liberation(s_etat_processus,
1.1 bertrand 5911: (*((struct_liste_chainee *)
1.197 bertrand 5912: l_element_courant)).donnee);
5913: free((struct_liste_chainee *) l_element_courant);
1.1 bertrand 5914:
5915: l_element_courant = l_element_suivant;
5916: }
5917:
1.197 bertrand 5918: while((*s_etat_processus).s_bibliotheques != NULL)
1.1 bertrand 5919: {
1.197 bertrand 5920: retrait_bibliotheque(s_etat_processus,
5921: (struct_bibliotheque *)
1.1 bertrand 5922: (*((struct_liste_chainee *)
1.197 bertrand 5923: (*s_etat_processus).s_bibliotheques)).donnee);
1.1 bertrand 5924: }
5925:
5926: l_element_courant = (void *) (*s_etat_processus)
5927: .l_base_pile_systeme;
5928: while(l_element_courant != NULL)
5929: {
5930: l_element_suivant = (*((struct_liste_pile_systeme *)
5931: l_element_courant)).suivant;
5932:
5933: liberation(s_etat_processus,
5934: (*((struct_liste_pile_systeme *)
5935: l_element_courant)).indice_boucle);
5936: liberation(s_etat_processus,
5937: (*((struct_liste_pile_systeme *)
5938: l_element_courant)).limite_indice_boucle);
5939: liberation(s_etat_processus,
5940: (*((struct_liste_pile_systeme *)
5941: l_element_courant)).objet_de_test);
5942:
5943: if ((*((struct_liste_pile_systeme *)
5944: l_element_courant)).nom_variable != NULL)
5945: {
5946: free((*((struct_liste_pile_systeme *)
5947: l_element_courant)).nom_variable);
5948: }
5949:
5950: free((struct_liste_pile_systeme *)
5951: l_element_courant);
5952:
5953: l_element_courant = l_element_suivant;
5954: }
5955:
5956: l_element_courant = (void *)
5957: (*s_etat_processus).s_fichiers;
5958: while(l_element_courant != NULL)
5959: {
5960: l_element_suivant = (*((struct_liste_chainee *)
5961: l_element_courant)).suivant;
5962:
5963: fclose((*((struct_descripteur_fichier *)
5964: (*((struct_liste_chainee *)
5965: l_element_courant)).donnee))
1.12 bertrand 5966: .descripteur_c);
5967:
5968: if ((*((struct_descripteur_fichier *)
5969: (*((struct_liste_chainee *)
5970: l_element_courant)).donnee)).type != 'C')
5971: {
5972: sqlite3_close((*((struct_descripteur_fichier *)
5973: (*((struct_liste_chainee *)
5974: l_element_courant)).donnee))
5975: .descripteur_sqlite);
5976: }
1.1 bertrand 5977:
5978: if ((*((struct_descripteur_fichier *)
5979: (*((struct_liste_chainee *)
5980: l_element_courant)).donnee))
5981: .effacement == 'Y')
5982: {
5983: unlink((*((struct_descripteur_fichier *)
5984: (*((struct_liste_chainee *)
5985: l_element_courant)).donnee))
5986: .nom);
5987: }
5988:
5989: free((*((struct_descripteur_fichier *)
5990: (*((struct_liste_chainee *)
5991: l_element_courant)).donnee)).nom);
5992: free((struct_descripteur_fichier *)
5993: (*((struct_liste_chainee *)
5994: l_element_courant)).donnee);
5995: free(l_element_courant);
5996:
5997: l_element_courant = l_element_suivant;
5998: }
5999:
6000: l_element_courant = (void *)
6001: (*s_etat_processus).s_sockets;
6002: while(l_element_courant != NULL)
6003: {
6004: l_element_suivant = (*((struct_liste_chainee *)
6005: l_element_courant)).suivant;
6006:
6007: if ((*((struct_socket *)
6008: (*(*((struct_liste_chainee *)
6009: l_element_courant)).donnee).objet))
6010: .socket_connectee == d_vrai)
6011: {
6012: shutdown((*((struct_socket *)
6013: (*(*((struct_liste_chainee *)
6014: l_element_courant)).donnee).objet))
6015: .socket, SHUT_RDWR);
6016: }
6017:
6018: close((*((struct_socket *)
6019: (*(*((struct_liste_chainee *)
6020: l_element_courant)).donnee).objet)).socket);
6021:
6022: if ((*((struct_socket *) (*(*((struct_liste_chainee *)
6023: l_element_courant)).donnee).objet)).effacement
6024: == 'Y')
6025: {
6026: unlink((*((struct_socket *)
6027: (*(*((struct_liste_chainee *)
6028: l_element_courant)).donnee).objet))
6029: .adresse);
6030: }
6031:
6032: liberation(s_etat_processus,
6033: (*((struct_liste_chainee *)
6034: l_element_courant)).donnee);
6035: free(l_element_courant);
6036:
6037: l_element_courant = l_element_suivant;
6038: }
6039:
6040: l_element_courant = (void *)
6041: (*s_etat_processus).s_connecteurs_sql;
6042: while(l_element_courant != NULL)
6043: {
6044: l_element_suivant = (*((struct_liste_chainee *)
6045: l_element_courant)).suivant;
6046:
6047: sqlclose((*((struct_liste_chainee *)
6048: l_element_courant)).donnee);
6049: liberation(s_etat_processus,
6050: (*((struct_liste_chainee *)
6051: l_element_courant)).donnee);
6052: free(l_element_courant);
6053:
6054: l_element_courant = l_element_suivant;
6055: }
6056:
6057: l_element_courant = (*s_etat_processus).s_marques;
6058: while(l_element_courant != NULL)
6059: {
6060: free((*((struct_marque *) l_element_courant)).label);
6061: free((*((struct_marque *) l_element_courant)).position);
6062: l_element_suivant = (*((struct_marque *)
6063: l_element_courant)).suivant;
6064: free(l_element_courant);
6065: l_element_courant = l_element_suivant;
6066: }
6067: }
6068: else
6069: {
6070: erreur = d_es_allocation_memoire;
6071:
6072: if (test_cfsf(s_etat_processus, 51) == d_faux)
6073: {
6074: printf("%s", ds_beep);
6075: }
6076:
6077: if ((*s_etat_processus).langue == 'F')
6078: {
6079: printf("+++Système : Mémoire insuffisante\n");
6080: }
6081: else
6082: {
6083: printf("+++System : Not enough memory\n");
6084: }
6085: }
6086: }
6087:
6088: liberation_allocateur(s_etat_processus);
6089: }
6090:
6091: if (traitement_fichier_temporaire == 'Y')
6092: {
1.124 bertrand 6093: destruction_fichier(nom_fichier_temporaire);
1.1 bertrand 6094: free(nom_fichier_temporaire);
6095: }
6096:
6097: if ((*s_etat_processus).profilage == d_vrai)
6098: {
6099: ecriture_profil(s_etat_processus);
6100: liberation_profil(s_etat_processus);
6101: }
6102: }
6103:
6104: closelog();
6105:
6106: pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes));
6107:
6108: retrait_thread(s_etat_processus);
6109:
1.185 bertrand 6110: attente.tv_sec = 0;
6111: attente.tv_nsec = GRANULARITE_us * 1000;
6112:
6113: while(nombre_thread_surveillance_processus != 0)
6114: {
6115: nanosleep(&attente, NULL);
6116: INCR_GRANULARITE(attente.tv_nsec);
6117: }
1.184 bertrand 6118:
1.199 bertrand 6119: attente.tv_sec = 0;
6120: attente.tv_nsec = GRANULARITE_us * 1000;
6121:
6122: while(pthread_mutex_trylock(&((*s_etat_processus).mutex_pile_processus))
6123: == EBUSY)
6124: {
6125: nanosleep(&attente, NULL);
6126: INCR_GRANULARITE(attente.tv_nsec);
6127: }
6128:
6129: pthread_mutex_unlock(&((*s_etat_processus).mutex_pile_processus));
1.146 bertrand 6130: pthread_mutex_destroy(&((*s_etat_processus).mutex_pile_processus));
1.30 bertrand 6131: pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation));
1.146 bertrand 6132: pthread_mutex_destroy(&((*s_etat_processus).mutex_interruptions));
1.117 bertrand 6133: pthread_mutex_destroy(&mutex_sections_critiques);
1.128 bertrand 6134: pthread_mutex_destroy(&mutex_liste_variables_partagees);
1.29 bertrand 6135:
1.199 bertrand 6136: free((*s_etat_processus).localisation);
6137:
6138: destruction_queue_signaux(s_etat_processus);
6139: pthread_mutex_destroy(&((*s_etat_processus).mutex_signaux));
6140: liberation_contexte_cas(s_etat_processus);
6141:
1.91 bertrand 6142: # ifndef SEMAPHORES_NOMMES
1.93 bertrand 6143: sem_post(&((*s_etat_processus).semaphore_fork));
6144: sem_destroy(&((*s_etat_processus).semaphore_fork));
1.91 bertrand 6145: # else
6146: sem_post((*s_etat_processus).semaphore_fork);
1.92 bertrand 6147: sem_destroy3((*s_etat_processus).semaphore_fork, getpid(), pthread_self(),
6148: SEM_FORK);
1.91 bertrand 6149: # endif
1.1 bertrand 6150:
1.40 bertrand 6151: free((*s_etat_processus).chemin_fichiers_temporaires);
1.103 bertrand 6152:
6153: if ((*s_etat_processus).requete_redemarrage == d_vrai)
6154: {
1.157 bertrand 6155: if (chdir(repertoire_initial) == 0)
6156: {
6157: execvp(arg_exec[0], &(arg_exec[0]));
6158: }
6159:
1.103 bertrand 6160: erreur = d_erreur;
6161: }
6162:
1.165 bertrand 6163: liberation_etat_processus_readline();
1.181 bertrand 6164:
1.164 bertrand 6165: liberation_allocateur_buffer(s_etat_processus);
1.167 bertrand 6166: pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation_buffer));
1.198 bertrand 6167: pthread_mutex_destroy(&mutex_liste_threads);
1.181 bertrand 6168:
1.165 bertrand 6169: sys_free(s_etat_processus);
1.181 bertrand 6170: sys_free(arg_exec);
1.24 bertrand 6171:
1.8 bertrand 6172: # ifdef DEBUG_MEMOIRE
1.24 bertrand 6173: debug_memoire_verification();
6174: analyse_post_mortem();
1.8 bertrand 6175: # endif
6176:
1.94 bertrand 6177: # ifdef HAVE_STACK_OVERFLOW_RECOVERY
6178: stackoverflow_deinstall_handler();
6179: # endif
6180:
6181: # ifdef HAVE_SIGSEGV_RECOVERY
6182: if (debug == d_faux)
6183: {
6184: sigsegv_deinstall_handler();
6185: }
6186: # endif
6187:
1.13 bertrand 6188: return((erreur == d_absence_erreur) ? EXIT_SUCCESS : EXIT_FAILURE);
1.1 bertrand 6189: }
6190:
6191:
6192: void
6193: informations(struct_processus *s_etat_processus)
6194: {
6195: printf("\n");
6196:
6197: if ((*s_etat_processus).langue == 'F')
6198: {
6199: printf(" rpl [-options] [programme]\n");
1.13 bertrand 6200: printf(" -a : analyse du code\n");
1.1 bertrand 6201: printf(" -A : paramètres passés au programme principal\n");
6202: printf(" -c : génération de fichier de débogage (rpl-core)\n");
6203: printf(" -d : option de déverminage interne\n");
6204: printf(" -D : lancement d'un daemon\n");
6205: printf(" -h : aide sur la ligne de commande\n");
6206: printf(" -i : fonctionnement interactif\n");
6207: printf(" -l : licence d'utilisation\n");
6208: printf(" -n : ignorance du signal HUP\n");
1.194 bertrand 6209: printf(" -m : chargement d'un module RPL/SO avant la "
6210: "compilation\n");
1.1 bertrand 6211: printf(" -p : précompilation du script avant exécution\n");
1.124 bertrand 6212: printf(" -P : profilage (-P ou -PP)\n");
1.1 bertrand 6213: printf(" -s : empêchement de l'ouverture de l'écran initial\n");
6214: printf(" -S : exécution du script passé en ligne de commande\n");
6215: printf(" -t : trace\n");
6216: printf(" -v : version\n");
6217: }
6218: else
6219: {
6220: printf(" rpl [-options] [program]\n");
1.13 bertrand 6221: printf(" -a : analyzes program\n");
1.1 bertrand 6222: printf(" -A : sends parameters to main program\n");
6223: printf(" -c : allows creation of a rpl-core file, providing a way"
6224: "\n"
6225: " to debug a program\n");
6226: printf(" -d : internal debug process\n");
6227: printf(" -D : starts in daemon mode\n");
6228: printf(" -h : shows a summary of available options\n");
6229: printf(" -i : runs the RPL/2 sequencer in interactive mode\n");
6230: printf(" -l : prints the user licence of the software\n");
6231: printf(" -n : ignores HUP signal\n");
1.194 bertrand 6232: printf(" -m : loads RPL/SO object before compilation\n");
1.1 bertrand 6233: printf(" -p : precompiles script\n");
1.124 bertrand 6234: printf(" -P : computes profile data (-P or -PP)\n");
1.1 bertrand 6235: printf(" -s : disables splash screen\n");
6236: printf(" -S : executes script written in command line\n");
6237: printf(" -t : enables tracing mode\n");
6238: printf(" -v : prints the version number\n");
6239: }
6240:
6241: printf("\n");
6242:
6243: return;
6244: }
6245:
1.96 bertrand 6246:
1.100 bertrand 6247: logical1
6248: controle_integrite(struct_processus *s_etat_processus,
6249: unsigned char *executable_candidat, unsigned char *executable)
6250: {
6251: unsigned char *md5;
6252: unsigned char *sha1;
6253:
6254: if (strcmp(executable, "rplpp") == 0)
6255: {
6256: md5 = rplpp_md5;
6257: sha1 = rplpp_sha1;
6258: }
6259: else if (strcmp(executable, "rplfile") == 0)
6260: {
6261: md5 = rplfile_md5;
6262: sha1 = rplfile_sha1;
6263: }
6264: else if (strcmp(executable, "rpliconv") == 0)
6265: {
6266: md5 = rpliconv_md5;
6267: sha1 = rpliconv_sha1;
6268: }
6269: else if (strcmp(executable, "rplawk") == 0)
6270: {
6271: md5 = rplawk_md5;
6272: sha1 = rplawk_sha1;
6273: }
6274: else if (strcmp(executable, "rplconvert") == 0)
6275: {
6276: md5 = rplconvert_md5;
6277: sha1 = rplconvert_sha1;
6278: }
6279: else
6280: {
6281: return(d_faux);
6282: }
6283:
6284: if (controle(s_etat_processus, executable_candidat, "md5", md5) != d_vrai)
6285: {
6286: return(d_faux);
6287: }
6288:
6289: if (controle(s_etat_processus, executable_candidat, "sha1", sha1) != d_vrai)
6290: {
6291: return(d_faux);
6292: }
6293:
6294: return(d_vrai);
6295: }
6296:
6297:
1.96 bertrand 6298: unsigned char *
1.165 bertrand 6299: date_compilation(struct_processus *s_etat_processus)
1.96 bertrand 6300: {
6301: unsigned char *date;
6302:
6303: if ((date = malloc((strlen(d_date_en_rpl) + 1) * sizeof(unsigned char)))
6304: == NULL)
6305: {
6306: return(NULL);
6307: }
6308:
6309: strcpy(date, d_date_en_rpl);
6310:
6311: return(date);
6312: }
6313:
1.156 bertrand 6314: #pragma GCC diagnostic pop
6315:
1.1 bertrand 6316: // vim: ts=4