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