Set SIGALRM handler before setting timer
This commit is contained in:
parent
d791054cfe
commit
0f96d32d4c
1 changed files with 2 additions and 2 deletions
4
echoc.c
4
echoc.c
|
@ -174,6 +174,8 @@ main(int argc, char *argv[])
|
|||
if (setsockopt(sock, IPPROTO_IP, IP_MTU_DISCOVER, &ch, sizeof(ch)) < 0)
|
||||
err(2, "setsockopt IP_MTU_DISCOVER");
|
||||
#endif
|
||||
signal(SIGALRM, send_packet);
|
||||
|
||||
/* timer values */
|
||||
itv.it_interval.tv_usec = interval*1000;
|
||||
itv.it_interval.tv_sec = 0;
|
||||
|
@ -182,8 +184,6 @@ main(int argc, char *argv[])
|
|||
if (setitimer(ITIMER_REAL, &itv, NULL) == -1)
|
||||
err(2, "setitimer");
|
||||
|
||||
signal(SIGALRM, send_packet);
|
||||
|
||||
gettimeofday(&last_ts, NULL);
|
||||
|
||||
while (1) {
|
||||
|
|
Loading…
Add table
Reference in a new issue