iptsd@.service stops itself ~6s after start on cold boot due to StopWhenUnneeded=yes - #219
Open
L0g0ff wants to merge 1 commit into
Open
Conversation
StopWhenUnneeded=yes was added in bcb12c6 alongside BindsTo=%I to make sure iptsd stops when its backing hidraw device is removed. BindsTo= already covers that case on its own (see systemd.unit(5): a unit bound to a device is stopped when the device is unplugged). StopWhenUnneeded= instead ties the unit's lifetime to whether any other active unit still "needs" it via a Wants=/Requires= dependency. Since iptsd@.service is only ever started through udev's SYSTEMD_WANTS on the hidraw device unit - a one-time job trigger, not a persistent Wants= - no unit ever durably "needs" it, so systemd stops iptsd a few seconds after every start, even while the device is still present. This breaks touch/pen on cold boot until the device is recreated (e.g. by suspend/resume, which re-triggers the udev rule). Removing StopWhenUnneeded= keeps the intended "stop when device is removed" behavior via BindsTo=, and fixes the premature-stop regression.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
iptsd@.servicesetsStopWhenUnneeded=yes, but the unit is only everactivated via udev's
SYSTEMD_WANTSon the hidraw device unit - aone-time job trigger, not a persistent
Wants=. As a result, systemddecides nothing "needs" the unit a few seconds after start and stops
it, even though the hidraw device is still present.
On cold boot this means: iptsd starts, connects to the IPTS device,
and is stopped by systemd itself ~6s later. Touch/pen then stop
working until the hidraw device is recreated (e.g. by suspend/resume,
which re-triggers the udev rule).
Evidence
StopWhenUnneeded=yeswas added in bcb12c6 together withBindsTo=%I(later fixed to%i.devicefor escaping in 72afde5),with the stated goal "make sure the service stops when the device is
removed."
systemd.unit(5),BindsTo=already fully covers that case:"...it also does so when a listed unit stops unexpectedly...the
backing device of a device unit might be unplugged."
StopWhenUnneeded=is a different, unrelated mechanism: "a unit willbe automatically cleaned up if no other active unit requires it" -
which is exactly what breaks here, since nothing durably "requires"
a udev-triggered instance.
Reproduction (Surface Pro 4, Fedora 44)
Manual workaround that confirms/fixes it:
systemctl edit iptsd@.servicewith
StopWhenUnneeded=no- service stays active across cold boot,touch/pen work normally. This has also been confirmed working on the
reporter's Surface Pro 4.
Fix
Remove
StopWhenUnneeded=-BindsTo=%i.devicealready provides theoriginally intended "stop on device removal" behavior.
Related KompassOS tracking issue: L0g0ff/KompassOS#85