-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverkill.c
54 lines (49 loc) · 803 Bytes
/
overkill.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "overkill.h"
void overkill()
{
int d=1,entered=0;
char * line = NULL;
char temp2[256]="/proc/\0";
int pid;
char *forexe[100]={NULL};
char cmd[100]={};
char pidst[100]={};
size_t len = 0;
ssize_t read;
FILE *fptr=fopen("jobs.txt","r");
while ((read = getline(&line, &len, fptr)) != -1)
{
char temp2[256]="/proc/\0";
if(d%2==0)
{
char *temp;
entered=1;
int r=0;
temp=line;
while(temp[r]!='[')
{
cmd[r]=temp[r];
r++;
}
forexe[0]=cmd;
int y=0;
r++;
while(temp[r]!=']')
{
pidst[y]=temp[r];
y++;r++;
}
pid=atoi(pidst);
strcat(temp2,pidst);
strcat(temp2,"/status");
if(fopen(temp2,"r"))
kill(pid,9);
}
d++;
}
while(arg[i][0]!=';')
{
i++;
}
fclose(fptr);
}