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