Describe the bug
During system shutdown, dinit stops services before the services that hard-depend on them (depends-on). At runtime the same dependency is enforced correctly: dinitctl stop refuses to stop the dependency while the dependent is running. During shutdown rollback, the order is ignored.
In my case, automount (autofs, serving a CIFS share) has depends-on for both wpa_supplicant-nm and NetworkManager. At shutdown, both of those stop first, the network goes down, and automount can't unmount the share. It then hangs until its stop-timeout expires and dinit kills it. Other pairs show the same pattern, e.g. dbus stopping before its hard dependents NetworkManager and elogind.
Things I've ruled out:
- No service uses
kill-all-on-stop(grep of/etc/dinit.dand/usr/lib/dinit.d). - Same behaviour with
loginctl poweroffandsudo dinitctl shutdown. - Happens with both dinit 0.22.0 and 0.22.1.
- With the network up,
dinitctl stop automountcompletes immediately. The service only hangs when its dependencies are stopped first.
To Reproduce
- Create
/etc/dinit.d/wpa_supplicant-nm:
type = process
command = /usr/bin/wpa_supplicant -u -s -O /run/wpa_supplicant
waits-for = dbus
before = NetworkManager- Create
/etc/dinit.d/automount:
type = process
command = /usr/bin/automount -f
depends-on = early-fs-local.target
depends-on = NetworkManager
depends-on = wpa_supplicant-nm
stop-timeout = 10/etc/dinit.d/NetworkManager (from the Artix package):
type = process
command = /usr/bin/NetworkManager -n
smooth-recovery = true
depends-on = dbus
depends-on = pre-network.target
before = network.target- Enable the services and reboot:
dinitctl enable wpa_supplicant-nm
dinitctl enable automount- Confirm the dependency is active at runtime:
$ sudo dinitctl stop wpa_supplicant-nm
dinitctl: cannot stop service 'wpa_supplicant-nm' due to the following dependents:
(only direct dependents are listed. Exercise caution before using '--force' !!)
automount-
Shut down with
sudo dinitctl shutdownorloginctl poweroff. -
The console shows:
[STOPPD] wpa_supplicant-nm
[STOPPD] NetworkManagerfollowed by a ~10 second pause, after which automount is killed for exceeding its stop time.
Expected behaviour
automount should stop first, while wpa_supplicant-nm and NetworkManager are still running. Only after automount has stopped should its dependencies be stopped. This matches the documented behaviour that a service process will not be signalled to terminate until its dependents have stopped.
Additional context
- Distro: Artix Linux
- dinit: 0.22.1 (
dinitanddinit-base0.22.1-1); also reproduced after downgrading to 0.22.0-3 - Desktop: KDE Plasma with the ly display manager; turnstiled runs a user dinit instance
- The share is CIFS, mounted by autofs through a direct map
- Kernel 7.2.9-artix1-1
Activity
2Thank you for developing and maintaining open source software!
Thanks for a thorough and detailed report. The fix was simple; it's a bit embarrassing that none of the tests caught the problem (I've added a test now that would do so).