-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsighandle.c
47 lines (39 loc) · 869 Bytes
/
sighandle.c
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
43
44
45
46
47
#include "headers.h"
#include "sighandle.h"
#include "prompt.h"
#include "main.h"
#include "list.h"
void ctrlC(int sig)
{
printf("\n");
ask_prompt();
fflush(stdout);
}
void ctrlZ(int sig)
{
printf("\n");
ask_prompt();
fflush(stdout);
}
void bgProcessExit(int sig)
{
int stat_loc;
pid_t pid = waitpid(-1, &stat_loc, WNOHANG);
if(pid > 0)
{
if(WIFEXITED(stat_loc) && WEXITSTATUS(stat_loc) == EXIT_SUCCESS)
{
fprintf(stderr, COL_FG_YLW "\r%s with pid %d exited normally\n" COL_RST, "Process", pid);
}
else
{
fprintf(stderr, COL_FG_RED "\r%s with pid %d exited abnormally\n" COL_RST, "Process", pid);
}
if(pid >= 0)
{
procList = delete(procList, pid, "po");
}
ask_prompt();
fflush(stdout);
}
}