Skip to content

Instantly share code, notes, and snippets.

@kashimAstro kashimAstro/sig.cpp
Created Mar 20, 2018

What would you like to do?
sample sig
#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
int main()
signal(SIGINT, signalExit);
signal(SIGTERM, signalExit);
signal(SIGKILL, signalExit);
cout<< "test"<< endl;
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.