В Wed, 1 Apr 2015 18:22:50 -0700 Kurt von Laven <k...@endlessm.com> пишет:
> Hello folks, > > I am trying to ensure that my system DBus service has time to handle a DBus > method call before it shuts down. My DBus service is implemented as a > system systemd service; let's call it service A. It runs a single-threaded, > synchronous event loop that listens for DBus method calls and handles them > appropriately. This event loop also listens for SIGTERM. When SIGTERM is > received, service A currently terminates the event loop, performs any > necessary writes to disk, and releases its resources. I am assuming that > when the system is shut down cleanly, systemd initially sends SIGTERM to > systemd services and only sends SIGKILL to abort it abruptly if it takes > too long to shut down when asked nicely. > > I have another system systemd service, call it service B, that runs an > event loop listening for SIGTERM. When service B receives a SIGTERM, it > makes the aforementioned DBus method call and then flushes the system bus. > Service B specifies Requires= > <http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Requires=>Service > A and After= > <http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Before=>Service > A. Service A makes no mention of service B in its unit configuration file. > Does systemd make any sort of guarantee that service A will get a chance to > handle the DBus method call before receiving SIGTERM, or does my code as > written have a race condition? > systemd will not initiate stopping of A before B has stopped. If it does, this should be considered a bug. So it is up to service B to handle termination correctly. Note that systemd will send SIGKILL after timeout if service has not terminated. _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel