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.") (documentation "Populate the /dev directory, dynamically.")
(start #~(lambda () (start #~(lambda ()
(define find
(@ (srfi srfi-1) find))
(define udevd (define udevd
;; Choose the right 'udevd'. ;; 'udevd' from eudev.
(find file-exists? #$(file-append udev "/sbin/udevd"))
(map (lambda (suffix)
(string-append #$udev suffix))
'("/libexec/udev/udevd" ;udev
"/sbin/udevd")))) ;eudev
(define (wait-for-udevd) (define (wait-for-udevd)
;; Wait until someone's listening on udevd's control ;; Wait until someone's listening on udevd's control
@ -1891,14 +1884,10 @@ (define (wait-for-udevd)
(make-static-device-nodes directory) (make-static-device-nodes directory)
(umask old-umask)) (umask old-umask))
(let ((pid (primitive-fork))) (let ((pid (fork+exec-command (list udevd))))
(case pid ;; Wait until udevd is up and running. This appears to
((0) ;; be needed so that the events triggered below are
(exec-command (list udevd))) ;; actually handled.
(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) (wait-for-udevd)
;; Trigger device node creation. ;; Trigger device node creation.
@ -1908,7 +1897,7 @@ (define (wait-for-udevd)
;; Wait for things to settle down. ;; Wait for things to settle down.
(system* #$(file-append udev "/bin/udevadm") (system* #$(file-append udev "/bin/udevadm")
"settle") "settle")
pid))))) pid)))
(stop #~(make-kill-destructor)) (stop #~(make-kill-destructor))
;; When halting the system, 'udev' is actually killed by ;; When halting the system, 'udev' is actually killed by