services: udev: Simplify 'start' method.

* gnu/services/base.scm (udev-shepherd-service)[start](find): Remove.
(udev): Hardwire the eudev file name.
Use 'fork+exec-command' instead of 'primitive-fork' and 'exec-command'.
This commit is contained in:
Ludovic Courtès 2018-09-19 10:54:46 +02:00
parent 4d679255da
commit 7fd3082522
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -1846,16 +1846,9 @@ (define udev-shepherd-service
(documentation "Populate the /dev directory, dynamically.")
(start #~(lambda ()
(define find
(@ (srfi srfi-1) find))
(define udevd
;; Choose the right 'udevd'.
(find file-exists?
(map (lambda (suffix)
(string-append #$udev suffix))
'("/libexec/udev/udevd" ;udev
"/sbin/udevd")))) ;eudev
;; 'udevd' from eudev.
#$(file-append udev "/sbin/udevd"))
(define (wait-for-udevd)
;; Wait until someone's listening on udevd's control
@ -1891,24 +1884,20 @@ (define (wait-for-udevd)
(make-static-device-nodes directory)
(umask old-umask))
(let ((pid (primitive-fork)))
(case pid
((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)
(let ((pid (fork+exec-command (list udevd))))
;; 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* #$(file-append udev "/bin/udevadm")
"trigger" "--action=add")
;; Trigger device node creation.
(system* #$(file-append udev "/bin/udevadm")
"trigger" "--action=add")
;; Wait for things to settle down.
(system* #$(file-append udev "/bin/udevadm")
"settle")
pid)))))
;; Wait for things to settle down.
(system* #$(file-append udev "/bin/udevadm")
"settle")
pid)))
(stop #~(make-kill-destructor))
;; When halting the system, 'udev' is actually killed by