GNOME Bugzilla – Bug 725492
Daemons started from dispatcher scripts get killed after 10 seconds
Last modified: 2014-04-18 15:46:06 UTC
Created attachment 270687 [details] Example dispatcher script that tries to start/stop named as connections go up/down If I start a daemon from a dispatcher script, it gets killed after 10 seconds no matter what. I've seen this happen with several different daemons, like pppd, named, and tayga. Indeed I haven't seen any daemon surviving for long after beings started from a dispatcher script. I'm attaching an example dispatcher script that simply start up named. With it installed, the following is logged when activating an connection: Mar 2 10:21:04 sloth nm-dispatcher.action: (named dispatcher script) starting named... Mar 2 10:21:04 sloth named[7147]: starting BIND 9.9.4-P2-RedHat-9.9.4-11.P2.fc20 -u named [...snip many messages from named...] Mar 2 10:21:04 sloth named[7147]: running Mar 2 10:21:04 sloth nm-dispatcher.action: (named dispatcher script) ...success! Mar 2 10:21:04 sloth nm-dispatcher.action: (named dispatcher script) reached end of script, exiting. Mar 2 10:21:14 sloth named[7147]: shutting down The messages above show that the named process did indeed daemonise and let the dispatcher script continue until it exited, so the problem can't be that NM is killing the dispatcher script for hanging around and not exiting. NM version: NetworkManager-0.9.9.0-30.git20131003.fc20.x86_64
after 10 seconds being idle, /usr/libexec/nm-dispatcher.action quits. It will be restarted by systemd when needed again. I think, when the process ends, systemd also kills off all children. You could probably change this by setting KillMode=process /usr/lib/systemd/system/NetworkManager-dispatcher.service . See http://www.freedesktop.org/software/systemd/man/systemd.kill.html It might be even better to configure named as its own systemd service so that it runs independently from the dispatcher service.
Indeed, setting KillMode=process does work. Consider this a wishlist for changing the default accordingly? Being able to start connection-specific processes from dispatcher scripts is a valid use-case, I think, and writing out a systemd service file and starting it in that way is pointless complexity (not to mention the fact that it won't work on distros not using systemd). named was just a zero-configuration-needed example that was easy to reproduce, really, the real use-cases I've had for this is starting TAYGA (for 464xlat) and pppd (to establish a secondary data bearer whenever NM takes up the primary). Tore
Yes, adding KillMode=process is probably the right thing to do.
fixed in git master