#!/bin/sh

msg='Stopping udevd...'
run() {
	# Stop udevd, we'll miss a few events while we run init, but we catch up
	udevadm settle
	udevadm control --stop-exec-queue

	read udevd_pid < /dev/.udev/udevd.pid
	kill "$udevd_pid"

	for sig in TERM KILL; do
		for proc in /proc/[0-9]*; do
			[ "$proc/exe" -ef "/sbin/udevd" ] ||
				continue
			kill -s "$sig" "${proc#/proc/}"
		done
		sleep 0.1
	done

	# ignore any failed event because the init script will trigger again all events
	rm -rf /dev/.udev
}
