-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjobs.h
50 lines (49 loc) · 959 Bytes
/
jobs.h
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef gh
#define gh
void jobs(){
FILE *fp = NULL;
fp = fopen(paths,"r+");
int counter = 0;
while(1 == 1){
char st[1024];
fgets(st,200,fp);
if(st[0] == '0')
continue;
if(feof(fp) !=0)
break;
int l = strlen(st+1);
char store[1024] = {'\0'};
for(int i=1;st[i]!=' ';i++)
store[i-1] = st[i];
char save[1024] = "/proc/",stor[1024]={'\0'};
int val = calculater(store,strlen(store)+1);
strcat(save,store);
strcat(save,"/status");
FILE *fil = fopen(save,"r");
if(!fil){
perror("File not opened");
return;
}
if(st[0]=='0')
continue;
else{
counter++;
FILE *fil = fopen(save,"r");
while(1 == 1){
fgets(stor,200,fil);
if(strstr(stor,"State")){
if(strstr(stor,"stopped")){
printf("[%d]\tStopped\t%s\n",counter,st+1+strlen(store));
}
else{
printf("[%d]\tRunning\t%s\n",counter,st+1+strlen(store));
}
break;
}
}
fclose(fil);
}
}
fclose(fp);
}
#endif