[systemd-devel] Different behaviour when sending SIGTERM
Marcos Mello
marcosfrm at gmail.com
Sun Mar 29 12:33:33 PDT 2015
Squid is known to be borked when running as a daemon (background):
http://bugs.squid-cache.org/show_bug.cgi?id=3826#c12
But still I am experiencing a difference between systemd's "built in" signal
delivery and systemctl kill.
# systemctl -l status squid.service
* squid.service - Squid Web Proxy Server
Loaded: loaded (/etc/systemd/system/squid.service; disabled)
Active: active (running) since Sun 2015-03-29 15:21:16 BRT; 20s ago
Process: 1488 ExecStart=/usr/sbin/squid $SQUID_OPTS (code=exited,
status=0/SUCCESS)
Main PID: 1491 (squid)
CGroup: /system.slice/squid.service
|-1489 /usr/sbin/squid -sX
|-1491 (squid-1) -sX
|-1492 (ssl_crtd) -s /var/lib/squid/ssl_db -M 4MB -b 4096
|-1493 (ssl_crtd) -s /var/lib/squid/ssl_db -M 4MB -b 4096
|-1494 (ssl_crtd) -s /var/lib/squid/ssl_db -M 4MB -b 4096
|-1495 (ssl_crtd) -s /var/lib/squid/ssl_db -M 4MB -b 4096
|-1496 (ssl_crtd) -s /var/lib/squid/ssl_db -M 4MB -b 4096
`-1497 (logfile-daemon) /var/log/squid/access.log
Mar 29 15:21:16 xxx.localdomain squid[1491]: 0 Objects cancelled.
Mar 29 15:21:16 xxx.localdomain squid[1491]: 0 Duplicate URLs purged.
Mar 29 15:21:16 xxx.localdomain squid[1491]: 0 Swapfile clashes avoided.
Mar 29 15:21:16 xxx.localdomain squid[1491]: Took 0.23 seconds ( 0.00
objects/sec).
Mar 29 15:21:16 xxx.localdomain squid[1491]: Beginning Validation Procedure
Mar 29 15:21:16 xxx.localdomain systemd[1]: squid.service: Supervising
process 1491 which is not our child. We'll most likely not notice when it exits.
Mar 29 15:21:16 xxx.localdomain squid[1491]: Completed Validation Procedure
Mar 29 15:21:16 xxx.localdomain squid[1491]: Validated 0 Entries
Mar 29 15:21:16 xxx.localdomain squid[1491]: store_swap_size = 0.00 KB
Mar 29 15:21:16 xxx.localdomain squid[1491]: storeLateRelease: released 0
objects
After 'systemctl stop squid.service':
# strace -f -e trace=process -p 1491
Process 1491 attached
+++ killed by SIGKILL +++
When I run 'systemctl kill --kill-who=main squid.service':
# strace -f -e trace=process -p 1510
Process 1510 attached
--- SIGTERM {si_signo=SIGTERM, si_code=SI_USER, si_pid=1, si_uid=0} ---
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=1516, si_uid=23,
si_status=SIGTERM, si_utime=0, si_stime=0} ---
wait4(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGTERM}], WNOHANG, NULL) = 1516
wait4(-1, 0x7ffd9ffe6624, WNOHANG, NULL) = 0
exit_group(0) = ?
+++ exited with 0 +++
The modified service file:
# /etc/systemd/system/squid.service
[Unit]
Description=Squid Web Proxy Server
After=network.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/squid.pid
EnvironmentFile=/etc/sysconfig/squid
#ExecStartPre=/usr/local/libexec/cache_swap.sh
ExecStart=/usr/sbin/squid $SQUID_OPTS
ExecReload=/usr/bin/kill -HUP $MAINPID
#ExecStop=/usr/sbin/squid -k shutdown
KillMode=process
SendSIGKILL=no
[Install]
WantedBy=multi-user.target
Reload works fine. 'squid -k shutdown' (it just sends SIGTERM to the pid
file process) works fine. Any clues? This is Fedora 21 (systemd-216-21)
running squid-3.4.12-2 from updates-testing.
More information about the systemd-devel
mailing list