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