SummaryRefsLogTreeCommitDiffStats
path: root/mcron-core.scm
diff options
context:
space:
mode:
authordale_mellor <dale_mellor>2006-04-16 22:10:43 +0000
committerdale_mellor <dale_mellor>2006-04-16 22:10:43 +0000
commit011df9b8fd152554619f76ea1e35a68ef206762d (patch)
tree2bee99d42aa1f0e984b0af546c6f92e7aaf8416f /mcron-core.scm
parent4c3a7cc36c29ecbb8574454f0f5bdbed7ef66f8b (diff)
downloadmcron-011df9b8fd152554619f76ea1e35a68ef206762d.tar.gz
mcron-011df9b8fd152554619f76ea1e35a68ef206762d.tar.bz2
mcron-011df9b8fd152554619f76ea1e35a68ef206762d.zip
Update to 1.0.3. Lots of small changes, mainly to work with guile 1.8.0. Daylight savings time is now handled okay. Bug fix in Vixie parser. User gets option to correct bad crontab entries.1.0.3
Diffstat (limited to 'mcron-core.scm')
-rw-r--r--mcron-core.scm67
1 files changed, 43 insertions, 24 deletions
diff --git a/mcron-core.scm b/mcron-core.scm
index 631311a..b8ca289 100644
--- a/mcron-core.scm
+++ b/mcron-core.scm
@@ -167,7 +167,7 @@
((eqv? count 0))
(and-let* ((next-jobs (find-next-jobs))
(time (car next-jobs))
- (date-string (strftime "%c\n" (localtime time))))
+ (date-string (strftime "%c %z\n" (localtime time))))
(for-each (lambda (job)
(display date-string)
(display (job:displayable job))
@@ -214,6 +214,16 @@
+;; Give any zombie children a chance to die, and decrease the number known to
+;; exist.
+
+(define (child-cleanup)
+ (do () ((or (<= number-children 0)
+ (eqv? (car (waitpid WAIT_ANY WNOHANG)) 0)))
+ (set! number-children (- number-children 1))))
+
+
+
;; Now the main loop. Loop over all job specifications, get a list of the next
;; ones to run (may be more than one). Set an alarm and go to sleep. When we
;; wake, run the jobs and reap any children (old jobs) that have
@@ -227,26 +237,35 @@
(define (run-job-loop . fd-list)
- (call-with-current-continuation (lambda (break)
-
- (let ((fd-list (if (null? fd-list) '() (car fd-list))))
-
- (let loop ()
-
- (let* ((next-jobs (find-next-jobs))
- (next-time (car next-jobs))
- (next-jobs-list (cdr next-jobs))
- (sleep-time (if next-time (- next-time (current-time))
- 2000000000)))
-
- (and (> sleep-time 0)
- (if (not (null? (car (select fd-list '() '() sleep-time))))
- (break)))
-
- (run-jobs next-jobs-list)
-
- (do () ((or (<= number-children 0)
- (eqv? (car (waitpid WAIT_ANY WNOHANG)) 0)))
- (set! number-children (- number-children 1)))
-
- (loop)))))))
+ (call-with-current-continuation
+ (lambda (break)
+
+ (let ((fd-list (if (null? fd-list) '() (car fd-list))))
+
+ (let loop ()
+
+ (let* ((next-jobs (find-next-jobs))
+ (next-time (car next-jobs))
+ (next-jobs-list (cdr next-jobs))
+ (sleep-time (if next-time (- next-time (current-time))
+ 2000000000)))
+
+ (and (> sleep-time 0)
+ (if (not (null?
+ (catch 'system-error
+ (lambda ()
+ (car (select fd-list '() '() sleep-time)))
+ (lambda (key . args) ;; Exception add by Sergey
+ ;; Poznyakoff.
+ (if (member (car (last args))
+ (list EINTR EAGAIN))
+ (begin
+ (child-cleanup) '())
+ (apply throw key args))))))
+ (break)))
+
+ (run-jobs next-jobs-list)
+
+ (child-cleanup)
+
+ (loop)))))))