Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subprocesses spawned by services get killed on service exit #73

Closed
heftig opened this issue Oct 24, 2017 · 2 comments
Closed

Subprocesses spawned by services get killed on service exit #73

heftig opened this issue Oct 24, 2017 · 2 comments

Comments

@heftig
Copy link

heftig commented Oct 24, 2017

When services spawn subprocesses, because systemd defaults to KillMode=control-group, these processes get killed as well when the main process exits.

This is unfortunate as it also applies to applications spawned when e.g. opening files in Nautilus or via Nautilus' search provider.

If the D-Bus service configures a SystemdService, this can be fixed by setting KillMode=process in the unit file. So far, so good.

However, this does not work for the transient units generated by dbus-broker; supplying KillMode process results in a different problem: If the control group still exists, starting the transient unit will fail.

@heftig
Copy link
Author

heftig commented Nov 1, 2017

A few possible solutions:

  • Give each transient unit instance an unique name to avoid the unit conflicting with itself
  • Replace transient units with a generator producing static units, which have the expected start behavior
  • Change systemd to make it possible for transient units with the same name to behave more like a (reloaded) static unit

teg added a commit to teg/dbus-broker that referenced this issue Nov 2, 2017
This allows forked-off children to survive their parents in case the
bus-activated parent is shut down before one of their children. Moreover,
make sure to give each transient unit file a unique name, so that a
new instance can be started, even if children of an old one are still
alive.

This addresses issue bus1#11 and bus1#73, implementing a suggestion given in
the latter.

Reported-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
Reported-by: Jan Alexander Steffens<jan.steffens@gmail.com>
Signed-off-by: Tom Gundersen <teg@jklm.no>
@teg
Copy link
Contributor

teg commented Nov 2, 2017

Thanks for the report! We had a similar report in the past, but were resigned to the fact that we would differ from dbus-daemon in this (leaking subprocesses like this really sounds very wrong to me). However, if even gnome is affected, I guess we need to make this work. Using instantiated transient units (with KillMode=process) sounded good to me, so went that route.

teg added a commit that referenced this issue Nov 2, 2017
This allows forked-off children to survive their parents in case the
bus-activated parent is shut down before one of their children. Moreover,
make sure to give each transient unit file a unique name, so that a
new instance can be started, even if children of an old one are still
alive.

This addresses issue #11 and #73, implementing a suggestion given in
the latter.

Reported-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
Reported-by: Jan Alexander Steffens<jan.steffens@gmail.com>
Signed-off-by: Tom Gundersen <teg@jklm.no>
@teg teg closed this as completed Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants