Dear all:
How come the program below returns alarm clock but does not print "signal sent!!"?What did I do wrong?
Thanks
Code:
/* Using a signal handler */
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
sig_atomic_t sigusr1_count = 1;
void handler (int signal_number) {
printf("signal sent!!\n");
}
int main () {
int i;
struct sigaction sa;
memset (&sa, 0, sizeof(sa));
sa.sa_handler = handler;
sigaction (SIGUSR1, &sa, NULL);
alarm(1);
//kill (getpid(), SIGUSR1);
while (1) {
printf("Hello\n");
}
return 0;
}