]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
units/systemd-vconsole-setup: suppress error when service is restarted 27867/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 13 Jul 2023 08:22:54 +0000 (10:22 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 13 Jul 2023 08:56:52 +0000 (10:56 +0200)
The service has Type=oneshot, which means that the default value of SuccessExitStatus=0.
When multiple vtcon devices are detected, udev will restart the service after each
one. If this happens quickly enough, the old instance will get SIGTERM while it is
still running:

[    5.357341] (udev-worker)[593]: vtcon1: /usr/lib/udev/rules.d/90-vconsole.rules:12 RUN '/usr/bin/systemctl --no-block restart systemd-vconsole-setup.service
[    5.357439] (udev-worker)[593]: vtcon1: Running command "/usr/bin/systemctl --no-block restart systemd-vconsole-setup.service"
[    5.357485] (udev-worker)[593]: vtcon1: Starting '/usr/bin/systemctl --no-block restart systemd-vconsole-setup.service'
[    5.357537] (udev-worker)[609]: vtcon0: /usr/lib/udev/rules.d/90-vconsole.rules:12 RUN '/usr/bin/systemctl --no-block restart systemd-vconsole-setup.service
[    5.357587] (udev-worker)[609]: vtcon0: Running command "/usr/bin/systemctl --no-block restart systemd-vconsole-setup.service"
[    5.357634] (udev-worker)[609]: vtcon0: Starting '/usr/bin/systemctl --no-block restart systemd-vconsole-setup.service'
...
[    5.680529] systemd[1]: systemd-vconsole-setup.service: Trying to enqueue job systemd-vconsole-setup.service/restart/replace
[    5.680565] systemd[1]: systemd-vconsole-setup.service: Merged into running job, re-running: systemd-vconsole-setup.service/restart as 557
[    5.680600] systemd[1]: systemd-vconsole-setup.service: Enqueued job systemd-vconsole-setup.service/restart as 557
...
[    5.682334] systemd[1]: Received SIGCHLD from PID 744 ((le-setup)).
[    5.682377] systemd[1]: Child 744 ((le-setup)) died (code=killed, status=15/TERM)
[    5.682407] systemd[1]: systemd-vconsole-setup.service: Child 744 belongs to systemd-vconsole-setup.service.
[    5.682436] systemd[1]: systemd-vconsole-setup.service: Main process exited, code=killed, status=15/TERM
[    5.682471] systemd[1]: systemd-vconsole-setup.service: Failed with result 'signal'.
[    5.682518] systemd[1]: systemd-vconsole-setup.service: Service will not restart (manual stop)
[    5.682552] systemd[1]: systemd-vconsole-setup.service: Changed stop-sigterm -> failed

This is expected and not a problem. Let's treat SIGTERM as success so we don't
get this spurious "failure".

units/systemd-vconsole-setup.service.in

index a75f72e3aef054eb1452090ed2926f76cc2386dd..96417e19bda15c58d7262545e0ef9dc3603bbd5b 100644 (file)
@@ -19,6 +19,12 @@ Before=initrd-switch-root.target shutdown.target
 
 [Service]
 Type=oneshot
+# This service will be restarted by udev whenever a new vtcon device appears.
+# If the previous instance is still running, it shall be interrupted without
+# error.
+SuccessExitStatus=SIGTERM
 RemainAfterExit=yes
+
 ExecStart={{ROOTLIBEXECDIR}}/systemd-vconsole-setup
+
 ImportCredential=vconsole.*