/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program receives SIGUSR1 signals. */
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>

void my_handler(int signo) {
    fprintf(stdout,"Signal handler entered for signal number %d\n",signo);
}

void my_handler2(int signo) {
    fprintf(stdout,"Signal handler entered for signal number %d\n",signo);
}

int main() {
    struct sigaction act, act2;
    sigset_t sigset;
    
    fprintf(stdout,"Process ID is %ld\n", (long) getpid());
    sigemptyset(&sigset);
    sigaddset(&sigset, SIGALRM);
    sigprocmask(SIG_BLOCK, &sigset, NULL);
    sigemptyset(&act.sa_mask);
    act.sa_flags = SA_NOCLDSTOP;
    act.sa_handler = my_handler;
    if(sigaction(SIGUSR1, &act, NULL) < 0) {
      perror("Sigaction failed");
      exit(1);
    }
    fprintf(stdout,"Signal SIGUSR1 = %d ready\n",SIGUSR1);

    act2.sa_flags = SA_NOCLDSTOP;
    act2.sa_handler = my_handler2;
    if(sigaction(SIGUSR2, &act2, NULL) < 0) {
      perror("Sigaction failed");
      exit(1);
    }
    fprintf(stdout,"Signal SIGUSR2 = %d ready\n",SIGUSR2);
    raise(SIGUSR1);
    raise(SIGUSR2);
}
       
