[systemd-devel] How to get all PIDs in a service
Sébastien Luttringer
seblu at seblu.net
Thu Jun 4 01:08:52 PDT 2015
Hello,
In order to restart updated daemons on filesystems, I created a
script[1] which lists all PID by service and look for updated files in
/proc/$pid/maps.
To get all PIDs of a service, I use "systemctl show -p ControlGroup" to
craft a path to the "tasks" file.
But something wrong happen with escaping with some units (e.g serial
-getty)
This works:
#cat /sys/fs/cgroup/systemd/$(systemctl show systemd-logind.service -p
ControlGroup|cut -f2 -d=)/tasks
286
This not:
#cat /sys/fs/cgroup/systemd/$(systemctl show serial-getty at ttyS0.service
-p ControlGroup|cut -f2 -d=)/tasks
/sys/fs/cgroup/systemd/$(systemctl show -p ControlGroup|cut -f2 -d=)
cat: /sys/fs/cgroup/systemd//system.slice/system-serial\
x5cx2dgetty.slice/serial-getty at ttyS0.service/tasks: No such file or
directory
What's the right way to get all pid belonging to a service? How can I
unescape strings from systemctl?
This is happening since a long time. I made these tests on systemd v220
et v219.
Cheers,
[1] https://github.com/seblu/archutils/blob/master/checkservices
--
Sébastien "Seblu" Luttringer
https://seblu.net | Twitter: @seblu42
GPG: 0x2072D77A
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150604/192ff832/attachment.sig>
More information about the systemd-devel
mailing list