services: dhcp-client: Better track dhclient's PID.
* gnu/services/networking.scm (dhcp-client-service)[start]: Remove PID-FILE first. When 'call-with-input-file' throws ENOENT, try again.
This commit is contained in:
parent
54d6223d2c
commit
c217cbd84d
|
@ -165,6 +165,8 @@ Protocol (DHCP) client, on all the non-loopback network interfaces."
|
||||||
(provision '(networking))
|
(provision '(networking))
|
||||||
|
|
||||||
(start #~(lambda _
|
(start #~(lambda _
|
||||||
|
(false-if-exception (delete-file #$pid-file))
|
||||||
|
|
||||||
;; When invoked without any arguments, 'dhclient'
|
;; When invoked without any arguments, 'dhclient'
|
||||||
;; discovers all non-loopback interfaces *that are
|
;; discovers all non-loopback interfaces *that are
|
||||||
;; up*. However, the relevant interfaces are
|
;; up*. However, the relevant interfaces are
|
||||||
|
@ -178,7 +180,19 @@ Protocol (DHCP) client, on all the non-loopback network interfaces."
|
||||||
"-pf" #$pid-file
|
"-pf" #$pid-file
|
||||||
ifaces))))
|
ifaces))))
|
||||||
(and (zero? (cdr (waitpid pid)))
|
(and (zero? (cdr (waitpid pid)))
|
||||||
(call-with-input-file #$pid-file read)))))
|
(let loop ()
|
||||||
|
(catch 'system-error
|
||||||
|
(lambda ()
|
||||||
|
(call-with-input-file #$pid-file read))
|
||||||
|
(lambda args
|
||||||
|
;; 'dhclient' returned before PID-FILE
|
||||||
|
;; was created, so try again.
|
||||||
|
(let ((errno (system-error-errno args)))
|
||||||
|
(if (= ENOENT errno)
|
||||||
|
(begin
|
||||||
|
(sleep 1)
|
||||||
|
(loop))
|
||||||
|
(apply throw args))))))))))
|
||||||
(stop #~(make-kill-destructor))))))
|
(stop #~(make-kill-destructor))))))
|
||||||
|
|
||||||
(define %ntp-servers
|
(define %ntp-servers
|
||||||
|
|
Loading…
Reference in New Issue