Created
March 20, 2018 10:19
-
-
Save kashimAstro/6b5abd6997918d49c606c759de95722b to your computer and use it in GitHub Desktop.
sample sig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <signal.h> | |
#include <iostream> | |
#include <unistd.h> | |
// kill -9 pid | |
// kill -15 pid | |
// kill pid | |
// Ctrl+c | |
using namespace std; | |
void signalExit(int sig){ | |
if (sig == SIGINT) | |
cout << "close SIGINT" << endl; | |
if (sig == SIGTERM) | |
cout << "close SIGTERM" << endl; | |
if (sig == SIGKILL) | |
cout << "close SIGKILL" << endl; | |
//unexport pin | |
exit(0); | |
} | |
int main() | |
{ | |
signal(SIGINT, signalExit); | |
signal(SIGTERM, signalExit); | |
signal(SIGKILL, signalExit); | |
while(1){ | |
cout<< "test"<< endl; | |
sleep(1); | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment