When well-known name disappears,
systemd sends SIGTERM to the service associated with the well-known name.
To prevent this, call sd_notify(0, "STOPPING=1") before unowing the name.
Journal log
===================================================================================================
sh-3.2# systemctl status stc-iptables.service
● stc-iptables.service - Smart Traffic Control Iptables
Loaded: loaded (/usr/lib/systemd/system/stc-iptables.service; disabled; vendor preset: enabled)
Active: inactive (dead) since Thu 2015-01-01 09:35:58 KST; 6s ago
Process: 367 ExecStart=/usr/bin/stc-iptables (code=killed, signal=TERM)
Main PID: 367 (code=killed, signal=TERM)
Jan 01 09:35:36 localhost systemd[1]: Starting Smart Traffic Control Iptables...
Jan 01 09:35:38 localhost systemd[1]: Started Smart Traffic Control Iptables.
Jan 01 09:35:58 localhost systemd[1]: stc-iptables.service: Succeeded.
===================================================================================================
Change-Id: I43434c79d8b3474917c9d96b6bd6ef0fa7b8571a
BuildRequires: pkgconfig(gio-unix-2.0)
BuildRequires: pkgconfig(libiptc)
BuildRequires: pkgconfig(libip6tc)
+BuildRequires: pkgconfig(libsystemd)
%if 0%{?gtests:1}
BuildRequires: pkgconfig(dlog)
ExecStart=/usr/bin/stc-iptables
Capabilities=cap_net_bind_service,cap_net_raw,cap_net_admin=i
SecureBits=keep-caps
+NotifyAccess=main
[Install]
WantedBy=multi-user.target
${COMMON_DEPS}
libiptc
libip6tc
+ libsystemd
)
INCLUDE(FindPkgConfig)
#include "stc-iptables.h"
#include "stc-iptables-gdbus.h"
#include "stc-iptables-util.h"
+#include <systemd/sd-daemon.h>
static gboolean __stc_iptables_gdbus_manager_init(stc_iptables_s *stc_iptables)
{
stc_iptables_s *stc_iptables = (stc_iptables_s *)stc_data;
+ sd_notify(0, "STOPPING=1");
g_bus_unown_name(stc_iptables->gdbus_owner_id);
stc_iptables->manager_obj = NULL;