1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| | diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 53437b6..bef8f42 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -715,21 +715,28 @@ number. Return #f if FILE was not created or does not contain a number;
otherwise return the number that was read (a PID)."
(define start (current-time))
(let loop ()
+ (define (retry)
+ (and (< (current-time) (+ start max-delay))
+ (begin
+ ;; FILE does not exist yet, so wait and try again.
+ ;; XXX: Ideally we would yield to the main event loop
+ ;; and/or use inotify.
+ (sleep 1)
+ (loop))))
+
(catch 'system-error
(lambda ()
- (string->number
- (string-trim-both
- (call-with-input-file file get-string-all))))
+ (define str
+ (call-with-input-file file get-string-all))
+
+ (local-output (l10n "read-pid-file ~s -> ~s")
+ file str)
+ (or (string->number (string-trim-both str))
+ (retry)))
(lambda args
(let ((errno (system-error-errno args)))
(if (= ENOENT errno)
- (and (< (current-time) (+ start max-delay))
- (begin
- ;; FILE does not exist yet, so wait and try again.
- ;; XXX: Ideally we would yield to the main event loop
- ;; and/or use inotify.
- (sleep 1)
- (loop)))
+ (retry)
(apply throw args)))))))
(define* (exec-command command
|