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