#include<stdio.h>
#include<unistd.h>
#include<signal.h>

void sighandler(int sig) {
	printf("%d PRRR\n", sig);
}

void sighandler2(int sig) {
	printf("2->%d PRRR\n", sig);
}

int main(int argc, char * argv[]){
	struct sigaction action = {.sa_handler = sighandler};
	sigaction(SIGINT, &action, NULL);
	for (;;) {
		struct sigaction newaction = {.sa_handler = sighandler2};
		struct sigaction old;
		sleep(1);
		printf("h2\n");
		sigaction(SIGINT, &newaction, &old);
		sleep(1);
		printf("back\n");
		sigaction(SIGINT, &old, NULL);
	}
}
