You are not logged in.

#1 2016-05-09 19:06:35

dz
Member
Registered: 2013-08-21
Posts: 16

Restart a systemd service without killing its children

I use a user-level systemd service to run a hotkey daemon.  For example, a key to open a terminal or web browser.  These terminals end up being children of the hotkey daemon, and restarting the daemon kills them.  Is there anything I can do to restart the parent process without killing the children?

`ExecReload` is not applicable in this case, and neither is patching the hotkey daemon.

Offline

#2 2016-05-09 20:34:42

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,740

Re: Restart a systemd service without killing its children

Can you set the hotkey up to disown the process after spawning it?     Maybe:  urxvt && disown

Edit:  Or, are the commands baked into the daemon?

Last edited by ewaller (2016-05-09 20:35:21)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2016-05-10 01:49:06

Wibjarm
Member
Registered: 2012-05-04
Posts: 43

Re: Restart a systemd service without killing its children

What you might want to do is set the hotkey daemon up to use systemd-run to launch things.  That way, the child processes are reparented to your systemd --user instance, and tracked as separate service (or scope) units rather than as part of the hotkey daemon's service.  That should do pretty much what you want.

Last edited by Wibjarm (2016-05-10 01:53:42)

Offline

#4 2016-05-10 02:12:55

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Restart a systemd service without killing its children

`man setsid`


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2016-05-10 15:16:12

dz
Member
Registered: 2013-08-21
Posts: 16

Re: Restart a systemd service without killing its children

Thanks everyone!  I used `setsid`, although `disown` would probably also work.

Offline

#6 2016-05-10 17:31:42

Vain
Member
Registered: 2008-10-19
Posts: 179
Website

Re: Restart a systemd service without killing its children

I'm confused. How can a simple `setsid` make the child processes leave the daemon's cgroup? Shouldn't systemd clean/kill the whole cgroup?

From my understanding, you should need to do what Wibjarm suggested.

Which hotkey daemon are you using? How does the actual unit file look like?

Just curious. smile

Offline

Board footer

Powered by FluxBB