#include #include void handler(int); int main(void) { if (signal(SIGUSR1, handler) == SIG_ERR) { fprintf(stderr, "cannot set handler for SIGUSR1\n"); exit(1); } if (signal(SIGUSR2, SIG_IGN) == SIG_ERR) { fprintf(stderr, "cannot set handler for SIGUSR2\n"); exit(1); } /* * Now wait for signals to arrive. */ for (;;) pause(); } /* * handler - handle a signal. */ void handler(int sig) { /* if (signal(SIGUSR1, handler) == SIG_ERR) { fprintf(stderr, "cannot set handler for SIGUSR1\n"); exit(1); } */ if (signal(SIGUSR2, SIG_IGN) == SIG_ERR) { fprintf(stderr, "cannot set handler for SIGUSR2\n"); exit(1); } /* * Print out what we received. */ psignal(sig, "Received signal"); }