There might be cases where we just need to ignore a specific signal. However, rest assured, there are few signals that cannot be ignored, for example, SIGKILL (uncatchable). This recipe will teach you how to ignore a catchable signal.
Learning how to ignore a signal
How to do it...
To ignore a catchable signal, follow these steps:
- On a shell, open a new source file called signal_ignore.cpp and start by adding the following code:
#include<stdio.h>
#include<signal.h>
#include <iostream>
int main()
{
std::cout << "Starting ..." << std::endl;
signal(SIGTERM, SIG_IGN);
while (true) ;
std::cout << "Ending ..." << std::endl;
return 0;
}
- In this...