summaryrefslogtreecommitdiff
path: root/usr.sbin/cron
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-05-21 20:57:33 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-05-21 20:57:33 +0000
commitd1b065d68012800c2340ac8ca18b2695aec1ce9e (patch)
tree8378f5c2583dca565d6d6aa1906dfd15005743dc /usr.sbin/cron
parent1d268fde0b26378f6982602df82ad519e9c65693 (diff)
Better handling of negative timeval than last commit.
Diffstat (limited to 'usr.sbin/cron')
-rw-r--r--usr.sbin/cron/cron.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c
index f029193ce56..1ae01bf981d 100644
--- a/usr.sbin/cron/cron.c
+++ b/usr.sbin/cron/cron.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cron.c,v 1.21 2002/05/20 23:33:31 millert Exp $ */
+/* $OpenBSD: cron.c,v 1.22 2002/05/21 20:57:32 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
*/
@@ -21,7 +21,7 @@
*/
#if !defined(lint) && !defined(LINT)
-static char rcsid[] = "$OpenBSD: cron.c,v 1.21 2002/05/20 23:33:31 millert Exp $";
+static char rcsid[] = "$OpenBSD: cron.c,v 1.22 2002/05/21 20:57:32 millert Exp $";
#endif
#define MAIN_PROGRAM
@@ -362,7 +362,7 @@ cron_sleep(int target) {
sizeof(fd_mask));
}
- while ((tv.tv_sec > 0 || tv.tv_usec > 0) && tv.tv_sec < 65) {
+ while (timerisset(&tv) && tv.tv_sec < 65) {
if (fdsr)
FD_SET(cronSock, fdsr);
/* Sleep until we time out, get a crontab poke, or signal. */
@@ -393,6 +393,10 @@ cron_sleep(int target) {
timersub(&t2, &t1, &t1);
timersub(&tv, &t1, &tv);
memcpy(&t1, &t2, sizeof(t1));
+ if (tv.tv_sec < 0)
+ tv.tv_sec = 0;
+ if (tv.tv_usec < 0)
+ tv.tv_usec = 0;
}
}