Bug 4655 - [patch] init.d spamassassin restart kills wrong process and fails
Summary: [patch] init.d spamassassin restart kills wrong process and fails
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Packaging: RPM (show other bugs)
Version: SVN Trunk (Latest Devel Version)
Hardware: Other other
: P2 normal
Target Milestone: 3.1.1
Assignee: SpamAssassin Developer Mailing List
Depends on:
Reported: 2005-10-31 04:24 UTC by Warren Togami
Modified: 2006-03-10 18:27 UTC (History)
0 users

Attachment Type Modified Status Actions Submitter/CLA Status
spamassassin-3.0.4-4655-initrd-kill-ppid.patch patch None Warren Togami [HasCLA]
just use /var/run/spamd.pid patch None Theo Van Dinter [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Warren Togami 2005-10-31 04:24:20 UTC
Sometimes "service spamassassin stop" fails on distros like Fedora because
killproc returns before spamd is fully dead.

  service spamassassin restart
  Shutting down spamd:                                       [  OK  ]
  Starting spamd: Could not create INET socket on Address already 
  in use (IO::Socket::INET: Address already in use)          [FAILED]    

This happens in instances where PPID wraparound happened.  It tried to kill the
first process named spamd, which is no longer the parent process, and thus
causes this failure.  Patch forthcoming target trunk, 3.1.1 and 3.0.5.
Comment 1 Warren Togami 2005-10-31 04:28:59 UTC
Created attachment 3219 [details]

Explicitly creates .pid file when service runs, and uses it in the .pid
killproc codepath during service stop.	This has the benefit of leaving alone
other instances of spamd that might also be running on the system.
Comment 2 Justin Mason 2005-10-31 04:36:10 UTC
Comment 3 Warren Togami 2005-11-07 20:13:44 UTC
Target 3.0.5, although this needs to be applied to other branches too.  Two more
votes needed.
Comment 4 Sidney Markowitz 2005-11-07 20:45:20 UTC
Comment 5 Sidney Markowitz 2005-11-07 20:46:34 UTC
If this is the place to vote for this for 3.1 too, here's my +1 for that.
Comment 6 Justin Mason 2005-11-07 23:35:16 UTC
explicitly: +1 for all
Comment 7 Justin Mason 2005-11-18 06:47:47 UTC
applied to trunk; revision 345454.
Comment 8 Henry Stern 2005-11-19 00:54:59 UTC
Patch applies cleanly and make test is happy.  +1 for 3.0.5 release.
Comment 9 Sidney Markowitz 2005-11-19 01:33:57 UTC
Committed revision 345610.

Leaving open to retarget to 3.1.1

Strictly speaking it needs one more vote before committing ot the 3.1.1 branch
because Henry voted just on 3.0.5.
Comment 10 Daryl C. W. O'Shea 2005-11-20 06:02:19 UTC
+1 for all

3.1 r345719

Comment 11 Theo Van Dinter 2006-03-10 22:08:31 UTC
I was just noticing that this doesn't quite work.


but nothing ever makes /var/run/spamassassin, so upon starting:

Mar 10 17:00:46 eclectic spamd[23924]: spamd: server started on port 783/tcp (running version 3.1.1) 
Mar 10 17:00:46 eclectic spamd[23924]: spamd: cannot write to PID file: No such file or directory 
Mar 10 17:00:46 eclectic spamd[23924]: spamd: server pid: 23924 

also, the pid file is never cleaned up.  in stop:

                rm -f /var/run/spamd.pid

which isn't the right path.

anyway, I'll put up a patch in a minute.
Comment 12 Theo Van Dinter 2006-03-10 22:14:05 UTC
Created attachment 3408 [details]
just use /var/run/spamd.pid
Comment 13 Justin Mason 2006-03-10 22:28:16 UTC
doesn't that need "-r $SPAMD_PID" on the spamd invocation line?
Comment 14 Justin Mason 2006-03-10 22:29:12 UTC
sorry, I get it; it's cumulative.  +1
Comment 15 Sidney Markowitz 2006-03-10 22:41:09 UTC

I keep thinking that there may be a reason why it was in a spamassassin
subdirectory and it made that symbolic link, perhaps some RedHat standard, but
1) most if not all of my daemons on my Fedora Core 4 system create pid files in
/var/run and don't do that symbolic link to the subdirectory thing, and 2) the
way this was just would not work unless something makes the spamassassin
subdirectory, which I don't see in the spec file and certainly is not true when
make install is done from source.

Unfortunately, I will not get to test a new tarball candidate for 3.1.1 until
about 8 or 9 hours from now :-(
Comment 16 Warren Togami 2006-03-10 22:51:30 UTC
I need to get a similar solution into Red Hat's package.

You are right, /var/run/spamd.pid is fine, we just have to be sure other parts
are using it properly.
Comment 17 Kenneth Porter 2006-03-11 02:23:09 UTC
(In reply to comment #15)
> +1
> I keep thinking that there may be a reason why it was in a spamassassin
> subdirectory and it made that symbolic link, perhaps some RedHat standard

Some packages use a /var/run subdirectory if the program writes the pid file
after it drops root privileges. (Similar measures must be taken with /var/log.)
Presumably spamd or its script did this in the past?
Comment 18 Theo Van Dinter 2006-03-11 02:27:30 UTC
committed, thanks.

Sending        spamd/redhat-rc-script.sh
Transmitting file data .
Committed revision 384991.