Im trying to handle SIGINT. Main purpose of SIGINT in my program cancelling current search function and printing the currently avaliable results. But whenever I try to catch a SIGINT signal it just closes my program. (I ve searched so much ,please just do not say that I have not searched enough)
I have tried :
basic signal handling(as shown as below)
sigaction functionality
non-local signal handling
sigprocmask (problem with procmask whenever I block a signal I cannot catch it but I need to catch and make printing on screen)
after all i have run out of search keyword to find a solution. Any idea ? (search keyword or part of code or logic way to do it ^^)
NOTE : This text may have grammar errors. Sorry for any mistakes.
#ifdef DEBUG
#define DPRINT(file ,message ,arg) fprintf(file ,message ,arg);
#define NDPRINT(file ,message) fprintf(file ,message);
#endif
static volatile sig_atomic_t isSignalCaught = 0;
void SIGHandler(int signo);
int main(int argc, char** argv)
{
file_t *files,*nextP;
signal(SIGINT, SIGHandler);
files = findFiles("/");
while (files != NULL) {
DPRINT(stderr, "%s\n", files->fileName.string);
nextP = files->pNext;
free(files->fileName.string);
free(files);
files = nextP;
}
return(0);
}
void SIGHandler(int signo)
{
file_t *nextP;
if (signo == SIGINT) {
isSignalCaught = 1;
}
}