Comment 21 for bug 573853

Revision history for this message
AlainKnaff (kubuntu-misc) wrote :

It seems that what is happening is that squid forks twice to demonize, but the "middle" process "forgets" to exit, and keeps hanging around.

# ps auxww | fgrep squid
root 2593 0.0 0.1 31792 4884 ? S 01:27 0:03 /usr/bin/perl /usr/sbin/squid-prefetch
root 14719 0.0 0.0 24796 1076 ? Ss 14:26 0:00 /usr/sbin/squid
proxy 14721 2.2 0.2 40212 10352 ? Sl 14:26 0:00 (squid)
root 14753 0.0 0.0 7576 820 pts/0 S+ 14:26 0:00 fgrep squid

# cat /var/run/squid.pid
14721

Here, 14719 is the son of the process started by init. It forks yet again, giving 14721, the program which does the actual work. Usually daemons do this in order to become fully independent of the program which launched them (so that they become inherited by init rather than whatever script launched them). However, when doing this, the middle process (14719) must exit, rather than staying around.

The result of this is that upstart becomes confused and thinks 14719 is the actual daemon, and sends it the signals instead of 14721. However, 14719 is not prepared to handle any signal, including SIGHUP, and so it exits without passing anything on to its child. Upstart notices 14719's exit, and thinks that squid is now fully gone, but it is not, as 14721 still happily chuggs along.

Adding SQUID_ARGS=-N to /etc/default/squid, and commenting out expect fork from /etc/init/squid fixes the issue.