--- rpl/src/instructions_s1.c 2019/07/19 06:53:29 1.112 +++ rpl/src/instructions_s1.c 2019/10/31 09:54:31 1.113 @@ -3454,7 +3454,6 @@ instruction_syseval(struct_processus *s_ { char **arguments; - int etape; int ios; int pipes_entree[2]; int pipes_erreur[2]; @@ -3465,6 +3464,7 @@ instruction_syseval(struct_processus *s_ logical1 drapeau_fin; logical1 presence_stdin; + logical1 processus_tue; long i; long nombre_arguments; @@ -4047,6 +4047,8 @@ instruction_syseval(struct_processus *s_ return; } + processus_tue = d_faux; + while((ios = (int) read_atomic_signal(s_etat_processus, pipes_sortie[0], &(tampon[pointeur]), (size_t) longueur_lecture)) >= 0) @@ -4097,15 +4099,7 @@ instruction_syseval(struct_processus *s_ if ((*s_etat_processus).var_volatile_requete_arret == -1) { gettimeofday(&horodatage_initial, NULL); - - if ((*s_etat_processus).var_volatile_alarme == -1) - { - kill(pid, SIGKILL); - } - else - { - kill(pid, SIGTERM); - } + kill(pid, SIGTERM); if ((fpipe = fdopen(pipes_sortie[0], "r")) == NULL) { @@ -4114,29 +4108,28 @@ instruction_syseval(struct_processus *s_ return; } - etape = 1; attente.tv_sec = 0; attente.tv_nsec = GRANULARITE_us * 1000; - fds.fd = pipes_sortie[0]; - fds.events = POLLIN; - - while(feof(fpipe) != 0) + if (kill(pid, 0) == 0) { - if (poll(&fds, 1, 0) > 0) - { - getc(fpipe); - attente.tv_sec = 0; - attente.tv_nsec = GRANULARITE_us * 1000; - } - else + while(feof(fpipe) == 0) { - nanosleep(&attente, NULL); - INCR_GRANULARITE(attente.tv_nsec); - } + fds.fd = pipes_sortie[0]; + fds.events = POLLIN; + + if (poll(&fds, 1, 0) > 0) + { + getc(fpipe); + attente.tv_sec = 0; + attente.tv_nsec = GRANULARITE_us * 1000; + } + else + { + nanosleep(&attente, NULL); + INCR_GRANULARITE(attente.tv_nsec); + } - if (etape == 1) - { gettimeofday(&horodatage_final, NULL); // Si au bout de 10 secondes après le premier @@ -4147,13 +4140,16 @@ instruction_syseval(struct_processus *s_ if ((horodatage_final.tv_sec - horodatage_initial.tv_sec) > 10) { - etape = 2; kill(pid, SIGKILL); gettimeofday(&horodatage_initial, NULL); + processus_tue = d_vrai; } } } + } + if (processus_tue == d_vrai) + { break; } }