Skip to content
Snippets Groups Projects
Commit f02f65ef authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

services: dhcp-client: Start 'dhclient' in "no wait" mode.

* gnu/services/networking.scm (dhcp-client-service): Pass '-nw' to
  'dhclient'.
parent 6a3f4c74
No related branches found
No related tags found
No related merge requests found
...@@ -107,10 +107,16 @@ (define pid-file ...@@ -107,10 +107,16 @@ (define pid-file
(with-monad %store-monad (with-monad %store-monad
(return (service (return (service
(documentation (documentation "Set up networking via DHCP.")
"Set up networking via DHCP.")
(requirement '(user-processes udev)) (requirement '(user-processes udev))
;; XXX: Running with '-nw' ("no wait") avoids blocking for a
;; minute when networking is unavailable, but also means that the
;; interface is not up yet when 'start' completes. To wait for
;; the interface to be ready, one should instead monitor udev
;; events.
(provision '(networking)) (provision '(networking))
(start #~(lambda _ (start #~(lambda _
;; 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
...@@ -121,7 +127,8 @@ (define pid-file ...@@ -121,7 +127,8 @@ (define pid-file
(ifaces (filter valid? (ifaces (filter valid?
(all-network-interfaces))) (all-network-interfaces)))
(pid (fork+exec-command (pid (fork+exec-command
(cons* #$dhclient "-pf" #$pid-file (cons* #$dhclient "-nw"
"-pf" #$pid-file
ifaces)))) ifaces))))
(and (zero? (cdr (waitpid pid))) (and (zero? (cdr (waitpid pid)))
(call-with-input-file #$pid-file read))))) (call-with-input-file #$pid-file read)))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment