Bug#791412: systemd invoking a service on its own

Michael Biebl biebl at debian.org
Mon Jul 6 08:58:56 BST 2015


Am 06.07.2015 um 09:29 schrieb Ritesh Raj Sarraf:
> rrs at learner:~$ cat /lib/udev/lmt-udev
> #!/bin/sh -e
> # /usr is not guaranteed to be mounted when udev starts
> 
> (
>         if grep -w "systemd" /proc/1/conn; then
>                 systemctl --non-block reload laptop-mode
> 
>         elif [ -e /lib/udev/hotplug.functions ]; then

> ) </dev/null >/dev/null 2>&1 &


> Please just confirm if this is the right approach, and I'll update the
> changes at other invokers too.

Something like that is going in the right direction.
You are backgrounding the subshell here, so there might still be issue
that the lmt-udev script is killed before you can call systemctl.
So I suspect there is still a race condition. I guess you could test
that by simply adding a sleep 10 before systemctl --non-block.

I would suggest moving the systemctl code outside of the backgrounded
subshell, i.e. the ( ) ... code block

See [1] as an example.


> BTW, Is this the reliable way to detect if systemd is the active running
> init ?

The canonical way to check if systemd is the active PID 1 is a simple
test for the existence of the /run/systemd/systemd directory [2]
In shell this would be
if [ -d /run/systemd/systemd ] ; then
  do stuff
fi

Michael

[1]
https://anonscm.debian.org/cgit/pkg-systemd/systemd.git/tree/debian/extra/udev-helpers/net.agent#n106
[2] http://www.freedesktop.org/software/systemd/man/sd_booted.html
-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20150706/a490bd8e/attachment-0002.sig>


More information about the Pkg-systemd-maintainers mailing list