diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-07-10 00:20:57 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-07-10 00:35:27 +0200 |
commit | ed09bb11cdd3454c00caf10615fac3cdd1791d55 (patch) | |
tree | 2e13d64e1c75c75b6da6e9ca71fbd57f129361f0 /gnu/services/base.scm | |
parent | 971436c6bdbeb68cbcc89437cb30b3be61ccae7a (diff) | |
download | guix-ed09bb11cdd3454c00caf10615fac3cdd1791d55.tar guix-ed09bb11cdd3454c00caf10615fac3cdd1791d55.tar.gz |
services: udev: Improve synchronization when starting.
* gnu/services/base.scm (udev-service)[start]: Add 'wait-for-udevd', and
call it before running 'udevadm trigger'. Pass --action=add to
'udevadm trigger'. Call 'udevadm settle' after 'udevadm trigger'.
Diffstat (limited to 'gnu/services/base.scm')
-rw-r--r-- | gnu/services/base.scm | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 030121625b..c430586dbf 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -409,6 +409,20 @@ hydra.gnu.org are used by default." (define udevd (string-append #$udev "/libexec/udev/udevd")) + (define (wait-for-udevd) + ;; Wait until someone's listening on udevd's control + ;; socket. + (let ((sock (socket AF_UNIX SOCK_SEQPACKET 0))) + (let try () + (catch 'system-error + (lambda () + (connect sock PF_UNIX "/run/udev/control") + (close-port sock)) + (lambda args + (format #t "waiting for udevd...~%") + (usleep 500000) + (try)))))) + ;; Allow udev to find the modules. (setenv "LINUX_MODULE_DIRECTORY" "/run/booted-system/kernel/lib/modules") @@ -418,12 +432,18 @@ hydra.gnu.org are used by default." ((0) (exec-command (list udevd))) (else + ;; Wait until udevd is up and running. This + ;; appears to be needed so that the events + ;; triggered below are actually handled. + (wait-for-udevd) + + ;; Trigger device node creation. + (system* (string-append #$udev "/bin/udevadm") + "trigger" "--action=add") + ;; Wait for things to settle down. (system* (string-append #$udev "/bin/udevadm") "settle") - ;; Create a bunch of devices. - (system* (string-append #$udev "/bin/udevadm") - "trigger") pid))))) (stop #~(make-kill-destructor)))))) |