From: Stroller <stroller@stellar.eclipse.co.uk>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] MailScanner: caught SIGTERM, aborting
Date: Sun, 24 May 2009 23:39:28 +0100 [thread overview]
Message-ID: <16B8463B-A6B5-4027-84B1-E524970BBDA7@stellar.eclipse.co.uk> (raw)
In-Reply-To: <4A194DAF.6090903@gmail.com>
On 24 May 2009, at 14:37, Jarry wrote:
> ...
> The /etc/init.d/MailScanner script looks so:
> ----------------------------------
> #!/sbin/runscript
> opts="${opts} reload"
> depend() {
> need net mta
> use logger dns }
>
> start() {
> ebegin "Starting MailScanner"
> /usr/sbin/check_MailScanner >/dev/null
> RETVAL=$?
> [ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/MailScanner
> [ ${RETVAL} -eq 0 ] && rm -f /var/lock/subsys/MailScanner.off
> eend ${RETVAL}
> }
>
> stop() {
> ebegin "Stopping MailScanner"
> killall -15 MailScanner
> RETVAL=$?
> [ ${RETVAL} -eq 0 ] && rm -f /var/lock/subsys/MailScanner
> [ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/MailScanner.off
> eend ${RETVAL}
> }
> # restart () {} and reload () {} removed
> ----------------------------------
That's the ugliest init.d script ever. It looks like it fell out of
the ugly tree, hit every branch on the way down and now not even its
mother could love it. &c &c.
Suggest you follow Mike's advice & rewrite the script based on the
other examples installed on your system, the ones written by Gentoo
devs. Unfortunately, if you don't know Bash very well, this may be a
bit of a mission, but I'm afraid it needs doing.
The script needs to save the process ID of the process that it starts
when it opens the application, then to stop the app it needs to kill
that specific PID, calling it by number. It needs to check that the
commands have worked - for instance: was it successful when it
executed `kill $PID`? See Example 6-1 of the Bash Scripting Guide <http://tldp.org/LDP/abs/html/exit-status.html
>. See also use of special variable $! in chapter 9 of ABSGuide and
also <http://www.unix.com/shell-programming-scripting/26377-pid-bash.html
>, but as Mike observes start-stop-daemon should take care of that
for you.
Stroller.
prev parent reply other threads:[~2009-05-24 22:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-24 9:10 [gentoo-user] MailScanner: caught SIGTERM, aborting Jarry
2009-05-24 9:48 ` Mike Kazantsev
2009-05-24 13:37 ` Jarry
2009-05-24 14:22 ` Mike Kazantsev
2009-05-24 14:36 ` Jarry
2009-05-25 0:17 ` Mike Kazantsev
2009-05-24 22:39 ` Stroller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16B8463B-A6B5-4027-84B1-E524970BBDA7@stellar.eclipse.co.uk \
--to=stroller@stellar.eclipse.co.uk \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox