-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkjob.c
More file actions
34 lines (33 loc) · 799 Bytes
/
kjob.c
File metadata and controls
34 lines (33 loc) · 799 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
#include "headers.h"
#include "kjob.h"
#include "back.h"
void kjob(char *inputs[], int args)
{
if (args != 3)
{
fprintf(stderr, "ERROR: Invalid number of arguments");
}
else
{
signal(SIGCHLD, handler);
int flag = 0;
int jobno = atoi(inputs[1]);
int signo = atoi(inputs[2]);
struct Node *copy = ll;
copy = copy->next;
struct Node *previous = ll;
for (int i = 0; i < jobno; i++)
{
if (copy == NULL)
{
fprintf(stderr, "ERROR: Job number does not exist\n");
flag = 1;
break;
}
previous = copy;
copy = copy->next;
}
if (flag == 0)
kill(previous->data, signo);
}
}