-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbg.c
More file actions
35 lines (31 loc) · 635 Bytes
/
bg.c
File metadata and controls
35 lines (31 loc) · 635 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
#include "headers.h"
void bg(int argc,char** argv)
{
if(argc>2)
{
printf("bg: too many arguments\n");
return;
}
else if(argc!=2)
{
printf("bg: less arguments\n");
return;
}
int job=atoi(argv[1]);
NodePtr temp=Get_Node_job(job);
if(temp==NULL)
{
printf("Error: job not found\n");
return;
}
pid_t pid=temp->pid;
if (pid <= 0) //sigcont signal resumes the process where it stopped
{
perror("Invalid command");
return;
}
if (kill(pid, SIGCONT) < 0)
{
perror("Can't send signal");
}
}