--- rpl/src/instructions_s1.c 2019/05/16 12:03:01 1.107 +++ rpl/src/instructions_s1.c 2019/06/17 13:27:35 1.108 @@ -3454,12 +3454,15 @@ instruction_syseval(struct_processus *s_ { char **arguments; + int etape; int ios; int pipes_entree[2]; int pipes_erreur[2]; int pipes_sortie[2]; int status; + file *fpipe; + logical1 drapeau_fin; logical1 presence_stdin; @@ -3486,6 +3489,9 @@ instruction_syseval(struct_processus *s_ struct timespec attente; + struct timeval horodatage_final; + struct timeval horodatage_initial; + unsigned char *ptr; unsigned char *ptr2; unsigned char registre_autorisation_empilement_programme; @@ -4078,6 +4084,8 @@ 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); @@ -4086,6 +4094,39 @@ instruction_syseval(struct_processus *s_ { kill(pid, SIGTERM); } + + if ((fpipe = fdopen(pipes_sortie[0], "r")) == NULL) + { + (*s_etat_processus).erreur_systeme = + d_es_erreur_fichier; + return; + } + + etape = 1; + + while((ios = getc(fpipe)) != EOF) + { + if (etape == 1) + { + gettimeofday(&horodatage_final, NULL); + + // Si au bout de 10 secondes après le premier + // signal, il reste des données à lire, le processus + // est sans doute encore actif. On envoie donc + // un signal 9. + + if ((horodatage_final.tv_sec - + horodatage_initial.tv_sec) > 10) + { + etape = 2; + kill(pid, SIGKILL); + gettimeofday(&horodatage_initial, NULL); + } + } + } + + fclose(fpipe); + break; } }