|
@@ -31,6 +31,20 @@ boolean is_numeric(const char* str){
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+void sort_pid(processus** proc, int size){
|
|
|
+ processus* tmp;
|
|
|
+ int index;
|
|
|
+ for(int i = 1; i < size; i++){
|
|
|
+ index = i;
|
|
|
+ while(index > 0 && proc[index]->pid < proc[index - 1]->pid){
|
|
|
+ tmp = proc[index];
|
|
|
+ proc[index] = proc[index - 1];
|
|
|
+ proc[index - 1] = tmp;
|
|
|
+ index--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
processus** list_process(int* nb){
|
|
|
struct dirent** dir;
|
|
|
struct stat info;
|
|
@@ -285,6 +299,8 @@ void printps(processus* proc){
|
|
|
int main(){
|
|
|
int total;
|
|
|
processus** proc = list_process(&total);
|
|
|
+ //Tri des processus par rapport à leur pid
|
|
|
+ sort_pid(proc, total);
|
|
|
for(int i = 0; i < total; i++){
|
|
|
//Recup info manquante
|
|
|
if(!read_status(proc[i])){
|