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