I have the following code. How to bring the control back to cleanupCode() when I received SIGINT while sleeping? I don’t want to use goto or jump. Calling cleanupCode inside handler is not an option.
sigHandler(int sig __atribute__((unused)) {
loopFlag = 0;
}
void cleanupCode()
{ printf("Graceful exit \n");
}
int main () {
while(loopFlag)
sleep(600);
cleanupCode();
}
This works for me: