[systemd-devel] systemd has not the same behaviour following the version of the kernel ; StopWhenUnneeded no longer works
eric-olivier.perrin at sysnav.fr
eric-olivier.perrin at sysnav.fr
Tue Sep 27 15:16:40 UTC 2022
Hi,
I'm using debian 10 (systemd 241) . I launch a service (tank.service) when a
specific USB device is connected. For that, i have written an udev rule that
requests the service start in case of < add > event, thanks to <
SYSTEMD_WANTS > :
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idVendor}=="04b4",
ATTRS{idProduct}=="6570", TAG+="systemd", ENV{SYSTEMD_WANTS}="tank.service"
I want service to be stopped when the USB device is removed. For that, I use
< StopWhenUnneeded > feature.
tank.service :
[Unit]
Description= tank routine
StopWhenUnneeded=true
[Service]
Type=simple
ExecStartPre=-/bin/bash /actimyo/bin/tankinsert.sh
ExecStart=/bin/bash /actimyo/bin/tank.sh
ExecStop=/bin/bash /actimyo/bin/tankremove.sh
With kernel 4.9.150 , it works well : the service is stopped when the USB
device is removed.
However, I updated the kernel to version 5.15.32 and the service do not stop
when the USB device is removed . The feature < StopWhenUnneeded > no longer
works.
Does anybody understand why ? Could anybody give me a solution ?
Systemd logs when USB device is removed with kernel 4.9.150 (complete logs
in attached file < logs systemd removing tank-4-9-150.txt >) :
Jun 17 09:21:34 b-0024 kernel: usb 1-1: USB disconnect, device number 2
Jun 17 09:21:34 b-0024 kernel: usb 1-1.2: USB disconnect, device number 3
Jun 17 09:21:34 b-0024 systemd[1]: tank.service: Unit is not needed anymore.
Jun 17 09:21:34 b-0024 systemd[1]: tank.service: Trying to enqueue job
tank.service/stop/fail
Jun 17 09:21:34 b-0024 systemd[1]: Added job tank.service/stop to
transaction.
Jun 17 09:21:34 b-0024 systemd[1]: tank.service: Installed new job
tank.service/stop as 724
Jun 17 09:21:34 b-0024 systemd[1]: tank.service: Enqueued job
tank.service/stop as 724
Jun 17 09:21:34 b-0024 systemd[1]: Sent message type=signal sender=n/a
destination=n/a path=/org/freedesktop/systemd1/unit/tank_2eservice
interface=org.freedesktop.DBus.Properties member=PropertiesChanged
cookie=605 reply_cookie=0 signature=sa{sv}as error-name=n/a
error-message=n/a
Jun 17 09:21:34 b-0024 systemd[1]: Sent message type=signal sender=n/a
destination=n/a path=/org/freedesktop/systemd1/unit/tank_2eservice
interface=org.freedesktop.DBus.Properties member=PropertiesChanged
cookie=606 reply_cookie=0 signature=sa{sv}as error-name=n/a
error-message=n/a
Jun 17 09:21:34 b-0024 systemd[1]: Sent message type=signal sender=n/a
destination=n/a path=/org/freedesktop/systemd1
interface=org.freedesktop.systemd1.Manager member=JobNew cookie=607
reply_cookie=0 signature=uos error-name=n/a error-message=n/a
Jun 17 09:21:34 b-0024 systemd[1]: tank.service: About to execute: /bin/bash
/actimyo/bin/tankremove.sh
Jun 17 09:21:34 b-0024 systemd[1]: tank.service: Forked /bin/bash as 2496
Jun 17 09:21:34 b-0024 systemd[1]: Sent message type=signal sender=n/a
destination=n/a path=/org/freedesktop/systemd1/unit/tank_2eservice
interface=org.freedesktop.DBus.Properties member=PropertiesChanged
cookie=608 reply_cookie=0 signature=sa{sv}as error-name=n/a
error-message=n/a
Jun 17 09:21:34 b-0024 systemd[1]: Sent message type=signal sender=n/a
destination=n/a path=/org/freedesktop/systemd1/unit/tank_2eservice
interface=org.freedesktop.DBus.Properties member=PropertiesChanged
cookie=609 reply_cookie=0 signature=sa{sv}as error-name=n/a
error-message=n/a
Jun 17 09:21:34 b-0024 systemd[1]: tank.service: Changed running -> stop
Jun 17 09:21:34 b-0024 systemd[1]: Stopping Detect tank presence...
Jun 17 09:21:34 b-0024 systemd[2496]: tank.service: Executing: /bin/bash
/actimyo/bin/tankremove.sh
Systemd logs when USB device is removed with kernel 5.15.32 (complete logs
in attached file < logs systemds removing tank kernel-5-15-32.txt >):
Jun 17 09:21:33 b-0021 kernel: [ 438.934344] usb 1-1: USB disconnect,
device number 2
Jun 17 09:21:33 b-0021 kernel: [ 438.939373] usb 1-1.2: USB disconnect,
device number 3
Jun 17 09:21:33 b-0021 systemd[1]: tank.service: tank.service lost
dependency
WantedBy=sys-devices-platform-soc-2100000.bus-2184000.usb-ci_hdrc.0-usb1-1\x
2d1.device
Jun 17 09:21:33 b-0021 systemd[1]: tank.service: tank.service lost
dependency
ReferencedBy=sys-devices-platform-soc-2100000.bus-2184000.usb-ci_hdrc.0-usb1
-1\x2d1.device
Best regards
---
Eric-Olivier Perrin
<mailto:eric-olivier.perrin at sysnav.fr> eric-olivier.perrin at sysnav.fr
--------------------------------------------
SYSNAV
72, rue Emile Loubet
27200 Vernon (France)
+33.(0)2.78.77.03.46
<http://www.sysnav.com/en/> www.sysnav.com
--------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20220927/1e91a64f/attachment-0001.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: logs systemd removing tank kernel-4-9-150.txt
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20220927/1e91a64f/attachment-0002.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: logs systemd removing tank kernel-5-15-32.txt
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20220927/1e91a64f/attachment-0003.txt>
More information about the systemd-devel
mailing list