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