diff options
author | Ludovic Courtès <ludo@gnu.org> | 2015-05-09 22:28:03 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2015-05-09 23:53:36 +0200 |
commit | c217cbd84d7aee7414945a6cf85e1d704fff6e32 (patch) | |
tree | 0bc04a347f1b450e4739a3e767f6b92f6be7463e | |
parent | 54d6223d2c240c0214c123e0b0aa977a01a3c209 (diff) | |
download | guix-c217cbd84d7aee7414945a6cf85e1d704fff6e32.tar guix-c217cbd84d7aee7414945a6cf85e1d704fff6e32.tar.gz |
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.
-rw-r--r-- | gnu/services/networking.scm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index f9d262d977..33ecf9ccd3 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -165,6 +165,8 @@ Protocol (DHCP) client, on all the non-loopback network interfaces." (provision '(networking)) (start #~(lambda _ + (false-if-exception (delete-file #$pid-file)) + ;; When invoked without any arguments, 'dhclient' ;; discovers all non-loopback interfaces *that are ;; up*. However, the relevant interfaces are @@ -178,7 +180,19 @@ Protocol (DHCP) client, on all the non-loopback network interfaces." "-pf" #$pid-file ifaces)))) (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)))))) (define %ntp-servers |