diff options
author | Jason Wright <jason@cvs.openbsd.org> | 2001-01-12 06:12:55 +0000 |
---|---|---|
committer | Jason Wright <jason@cvs.openbsd.org> | 2001-01-12 06:12:55 +0000 |
commit | 36a7fbd69a94ac66a8f93f5d4471c4213500a12c (patch) | |
tree | ac6d9345bbd41274333fe8d0782b79a9184b4f0a /usr.sbin/pppoe | |
parent | e1af9f48fda638d1df2585f141396f3dfe7e58ac (diff) |
use setitimer instead of alarm
Diffstat (limited to 'usr.sbin/pppoe')
-rw-r--r-- | usr.sbin/pppoe/client.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/usr.sbin/pppoe/client.c b/usr.sbin/pppoe/client.c index 084ef9e4201..65f123ce18a 100644 --- a/usr.sbin/pppoe/client.c +++ b/usr.sbin/pppoe/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.5 2000/10/09 22:52:18 brian Exp $ */ +/* $OpenBSD: client.c,v 1.6 2001/01/12 06:12:54 jason Exp $ */ /* * Copyright (c) 2000 Network Security Technologies, Inc. http://www.netsec.net @@ -539,6 +539,7 @@ timer_set(sec) u_int sec; { struct sigaction act; + struct itimerval it; timer_alarm = 0; if (sigemptyset(&act.sa_mask) < 0) @@ -547,17 +548,32 @@ timer_set(sec) act.sa_handler = timer_handler; if (sigaction(SIGALRM, &act, &timer_oact) < 0) return (-1); - alarm(sec); + + timerclear(&it.it_interval); + timerclear(&it.it_value); + it.it_value.tv_sec = sec; + if (setitimer(ITIMER_REAL, &it, NULL) == -1) { + sigaction(SIGALRM, &timer_oact, NULL); + return (-1); + } + return (0); } int timer_clr(void) { - alarm(0); - if (sigaction(SIGALRM, &timer_oact, NULL) < 0) - return (-1); + struct itimerval it; + int r1, r2; + + timerclear(&it.it_interval); + timerclear(&it.it_value); + r1 = setitimer(ITIMER_REAL, &it, NULL); + r2 = sigaction(SIGALRM, &timer_oact, NULL); timer_alarm = 0; + + if (r1 || r2) + return (-1); return (0); } |