Thank you for kicking me in the right direction
However I have another related question
Code:
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
void sig_stop(int signo){
if (signo == SIGINT){
printf("You are done: SIGINT\n");
exit(0);
}
}
int main(){
int i=0;
if (signal(SIGINT, sig_stop) == SIG_ERR)
printf("\nerror SIGINT\n");
while(i<10){
i++;
printf("i:%d\n",i);
sleep(1);
}
return 0;
}
So the above code is catching the SIGINT, and i know that the function prototipe for interrupt "= sig_end(int sig)" but is there a way to pass more arguments ?? so that i can do something before i exit() the program ??
PS
I want to avoid any global variables if possible. If not, then the solution is straightforward ...