-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
36 lines (30 loc) · 934 Bytes
/
main.cpp
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
#include <iostream>
#include <csignal>
// Common function to handle signals
void handleSignal(int signal)
{
std::cout << "Received signal: " << signal << std::endl;
// Add your common handling logic here
}
int main()
{
// Set up signal handlers for the signals of interest
signal(SIGTERM, handleSignal);
signal(SIGHUP, handleSignal);
signal(SIGINT, handleSignal);
signal(SIGABRT, handleSignal);
signal(SIGPIPE, handleSignal);
signal(SIGUSR1, handleSignal);
signal(SIGUSR2, handleSignal);
signal(SIGCHLD, handleSignal);
signal(SIGTSTP, handleSignal);
signal(SIGCONT, handleSignal);
signal(SIGTTIN, handleSignal);
signal(SIGTTOU, handleSignal);
// Your program logic here
// For demonstration, let's simulate some signals being sent
std::cout << "Simulating signals..." << std::endl;
raise(SIGTERM);
// Your program continues running
return 0;
}