-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkjob.c
More file actions
42 lines (41 loc) · 878 Bytes
/
kjob.c
File metadata and controls
42 lines (41 loc) · 878 Bytes
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
#include "headers.h"
void kjob(char * input_str)
{
// printf("INSIDE");
// return;
long long int i,j,k,token_cnt=0,job_id,signal;
char * token = strtok(input_str," ");
// printf("%s",token);
while(token!=NULL)
{
if(token_cnt==1)
{
job_id = atoi(token);
}
else if(token_cnt==2)
{
signal = atoi(token);
}
token = strtok(NULL," ");
token_cnt++;
}
// printf("%lld %lld",job_id,signal);
if(token_cnt<=2||token_cnt>=4)
{
printf("Inconsistent number of arguments\n");
return;
}
else
{
if(jobs[job_id].status == 1)
{
kill(jobs[job_id].pid,signal);
jobs[job_id].status = 0;
}
else
{
printf("No job to kill \n");
return;
}
}
}