I was trying following signal handler program , referring from an online tutorial , but it does not seems working , what is wrong with my code:
#include<signal.h>
#include<unistd.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
typedef void (*SignalHandlerPointer)(int);
static void UsrHostSigAbort(int pSignal)
{
//stopService();
printf("pankaj");
}
void HandleHostSignal()
{
struct sigaction satmp;
memset(&satmp, '\0' , sizeof(satmp));
SignalHandlerPointer usrSigHandler;
satmp.sa_flags &= ~SA_SIGINFO;
satmp.sa_handler = UsrHostSigAbort;
usrSigHandler = sigaction (SIGINT , &satmp, NULL);
}
void main()
{
HandleHostSignal();
while(1)
{
sleep(1);
}
}
I am compiling and running this program in ubuntu.