/* Copyright (c) 2001-2004 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);
}

int main() {
    struct sigaction act;
    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);
    if(sigaction(SIGUSR2, &act, NULL) < 0) {
      perror("Sigaction failed");
      exit(1);
    }
    fprintf(stdout,"Signal SIGUSR2 = %d ready\n",SIGUSR2);
    raise(SIGUSR1);
    my_handler(-100); /* testing only */
    raise(SIGUSR2);
}
       
