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