-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignals.cpp
More file actions
32 lines (29 loc) · 1.09 KB
/
signals.cpp
File metadata and controls
32 lines (29 loc) · 1.09 KB
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
#include <iostream>
#include <signal.h>
#include "signals.h"
#include "Commands.h"
using namespace std;
void ctrlZHandler(int sig_num) {
printf("smash: got ctrl-Z\n");
SmallShell& shell = SmallShell::getInstance();
if(shell.getFgJob() != nullptr) {
//if (shell.getFgJob()->getPid() != -1) {
shell.getJobsList()->addJob(shell.getFgJob()->getCmdLine(),shell.getFgJob()->getPid(),
true,shell.getFgJob()->getJobId());
kill(shell.getFgJob()->getPid(),19);
printf("smash: process %d was stopped\n",int(shell.getFgJob()->getPid()));
return;
}
//printf("smash: process was stopped\n");
}
void ctrlCHandler(int sig_num) {
printf("smash: got ctrl-C\n");
SmallShell& shell = SmallShell::getInstance();
if(shell.getFgJob() != nullptr) {
//if (shell.getFgJob()->getPid() != -1) {
kill(shell.getFgJob()->getPid(),9);
printf("smash: process %d was killed\n",int(shell.getFgJob()->getPid()));
return;
}
//printf("smash: process was killed\n");
}