#include #include #include #include "processlist.h" process * setStatus(process * pr ,int pid_proc, int status){ if(pr == NULL){} else if(pr->pid == pid_proc){ pr->status = status; } else{ setStatus(pr->procSuivant, pid_proc, status); } return pr; } process * supprimer(process* pr ,int pid_proc){ process * toDel; if(pr == NULL){} else{ if(pr->pid == pid_proc){ toDel = pr; pr = pr->procSuivant; } else{ process * tmp = pr; while(tmp->procSuivant->pid != pid_proc){ tmp = tmp->procSuivant; } toDel = tmp ->procSuivant; tmp->procSuivant = tmp->procSuivant->procSuivant; } free(toDel->commande); free(toDel); } return pr; } process * inserer(process * pr , int id, int pid, int status, char * commande){ process * toAdd = malloc(sizeof(process)); toAdd->id = id; toAdd->pid = pid; toAdd->status = status; toAdd->commande = commande; toAdd->procSuivant = pr; pr = toAdd; return pr; } int taille(process * pr){ if(pr == NULL) return 0; else return 1 + taille(pr->procSuivant); } int getPID(const process * pr, int idMinishell){ if(pr == NULL) return -1; if(pr->id == idMinishell){ return pr->pid; } else return getPID(pr->procSuivant, idMinishell); } void afficherProcess(process * pr){ if(pr != NULL){ printf("%-12d%-12d", pr->id, pr->pid); if(pr->status>0) printf("%-12s", "actif"); else printf("%-12s", "suspendu"); printf("%s", pr->commande); printf("\n"); afficherProcess(pr->procSuivant); } }