-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendsig.c
More file actions
41 lines (40 loc) · 693 Bytes
/
Copy pathsendsig.c
File metadata and controls
41 lines (40 loc) · 693 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
#include<signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
typedef struct Node{
pid_t pid_process;
char pname[100];
int num;
struct Node *next;
}node;
extern node * head;
node * temp;
extern int counter;
int sendsig(char **args)
{
int count=0,pno,pid,sig;
pno=atoi(args[1]); // stores process number
sig=atoi(args[2]); // stores signal number
temp=head->next;
if(pno>counter)
{
printf("Less Processes\n");
return 1;
}
while(temp)
{
if(temp->num == pno)
{
break;
}
temp=temp->next;
}
kill(temp->pid_process,sig);
return 1;
}