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