Hi,
Please could someone explain this simple timing code (to be used under Linux). I get most of it, but some of the struct members like sa_flags confuses me and I can't find something that explains it clearly.
I hope to use timing code in some of my projects. Is it possible to create multiple sigalarms at once?Code:#include <signal.h> #include <unistd.h> #include <stdio.h> volatile int stop=0; void sigalrm_handler( int sig ) { stop = 1; } int main(int argc, char **argv) { struct sigaction sact; int num_sent = 0; sigemptyset (&sact.sa_mask); sact.sa_flags = 0; sact.sa_handler = sigalrm_handler; sigaction(SIGALRM, &sact, NULL); alarm(1); /* Request SIGALRM in 60 seconds */ while (!stop) { printf("Sent"); num_sent++; } printf("sent %d packets\n", num_sent); return(0); }
Thanks in advance,
Joshun



1Likes
LinkBack URL
About LinkBacks


