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

	sig_atomic_t usr1Happened;

void sigint_handler(int sig){

	usr1Happened = 1;
}

int main(void) {

	struct sigaction sa;
	usr1Happened = 0;
	sa.sa_handler = sigint_handler;
	sa.sa_flags = 0; // or SA_RESTART
		sigemptyset(&sa.sa_mask);

	if (sigaction(SIGUSR1, &sa, NULL) == -1) {
			perror("sigaction");
			exit(1);
		}


	printf("PID = %d : Running...\n ",getpid());
	while(usr1Happened!=1){}



      printf("PID = %d : Received USR1\n",getpid());
      printf("PID = %d : Received Exiting\n",getpid());

	return 0;
}
