[systemd-devel] sub-processes handling question

Mirco Tischler mt-ml at gmx.de
Mon Jul 25 06:19:34 PDT 2011


2011/7/25 Honza Horak <hhorak at redhat.com>:
> Hi,
>
> I'm wondering how good systemd is in killing all sub-processes when a
> service fails/ends (un)expectedly. Let's say a service forks several times
> during its execution and the forked processes do some nasty work to detach
> from parent process. Can we be sure that all processes will be
> interrupted/killed after main service process ends/fails?
>
> Thanks for any reply
>
> Cheers,
>
> Honza
Basically yes. It's one of the features of systemd that no other init
system provides:)

Systemd uses cgroups to track childprocesses. A process can call
fork() as much as it wants, all the childprocesses will still be in
the same cgroup as their parent. On service stop systemdthen sends
TERM and later KILL signals to all the processes left in that
service's cgroup.
The only way to escape would be by the process removing itself from
the cgroup, which seems malicious to me and should never be done by
any sane service.

Mirco


More information about the systemd-devel mailing list