Code:
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
#define True 1
void (*sig_before)(int); /* to use for permutation */
void work() {
while(True){
sleep(100000);
}
}
void work() __attribute__((noreturn));
/* signal handlers */
void sighdl1(int n) {
printf("message number 1 \n");
}
void sighdl2(int n) {
printf("message number 2 \n");
}
void quithdlr(int n) {
printf("signal %i received, messages permutation", n);
}
/* the main of my program*/
int main() {
/* here I would like to use the call system signal and sig_before so that my program can swap from one signal handler to another when he receives a QUIT signal */
signal(SIGINT, sighdl1);
work();
}