-
Notifications
You must be signed in to change notification settings - Fork 0
/
jobs.c
32 lines (27 loc) · 952 Bytes
/
jobs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "headers.h"
void jobs(char* arg,int flag_r,int flag_s){
for(int i=0;i<process_count;i++){
if(process_count < 0){
break;
}
char /*pid[200],*/path[200],status;
int pid=process[i].pid;
sprintf(path,"/proc/%d/stat",pid);
int piid;
char comm[100];
if(process[i].stat == 'R' && flag_r == 1){
printf("[%d] Running %s [%d]\n",i+1,process[i].name,process[i].pid);
}
else if(process[i].stat == 'T' && flag_s == 1){
printf("[%d] Stopped %s [%d]\n",i+1,process[i].name,process[i].pid);
}
else if(flag_r == 0 && flag_s == 0){
if(process[i].stat == 'R'){
printf("[%d] Running %s [%d]\n",i+1,process[i].name,process[i].pid);
}
else{
printf("[%d] Stopped %s [%d]\n",i+1,process[i].name,process[i].pid);
}
}
}
}