-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcom_bg.h
More file actions
37 lines (33 loc) · 700 Bytes
/
Copy pathcom_bg.h
File metadata and controls
37 lines (33 loc) · 700 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
#ifndef COM_BG
#define COM_BG
#include "global.h"
int call_bg()
{
if (numargs != 2)
{
printf("%s: invalid number of arguments\n", commands[0]);
return 0;
}
if (str_is_num(commands[1]) == 0)
{
printf("%s: invalid argument\n", commands[0]);
return 0;
}
int arg1 = my_atoi(commands[1]);
if (arg1 > bgcommands_num || arg1 == 0)
{
printf("%s: no such job\n", commands[0]);
return 0;
}
if (getpgid(bgprocesses_ID[arg1 - 1]) >= 0)
{
if (kill(bgprocesses_ID[arg1 - 1], 18) >= 0)
return 1;
}
else
{
printf("Process has been terminated.\n");
}
return 0;
}
#endif